Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Spidermonkey shell 中,使用该read()函数读取文件会忽略文件的编码。有没有办法读取 UTF-8 或其他多字节编码文件并保留多字节字符?蜘蛛猴就是这样一个小恶魔。
read()
因此,我与 Mozilla 的 JS 人员进行了交谈。事实证明这不是完全可能的,所以他们添加了一个命令行标志来启用 UTF-8 支持read()和snarf().
snarf()
/usr/bin/js -e "print(read('filexyz.txt'))" -U
为了通过此添加获得 Spidermonkey 的副本,您必须使用 Tracemonkey 存储库。您可以使用 Mercurial 获得它:
hg clone http://hg.mozilla.org/tracemonkey/