【发布时间】:2021-10-09 06:28:53
【问题描述】:
当我尝试打印一个特殊的字符串时,我得到了混乱的代码:
const str = "\xa7\xe6\xd9\xe6\x95\xe6\xe4\xb0\x82L\x13"
console.log(str) // §æÙææä°L
// expect: the origin value, "\xa7\xe6\xd9\xe6\x95\xe6\xe4\xb0\x82L\x13".
看来终端会自动使用utf8对字符串进行编码。
当我使用节点时,如何打印或获取原始输入:"\xa7\xe6\xd9\xe6\x95\xe6\xe4\xb0\x82L\x13"?
【问题讨论】:
-
const str = "\\xa7\\xe6\\xd9\\xe6\\x95\\xe6\\xe4\\xb0\\x82L\\x13" -
接近尾声的
L是一个错误还是它应该存在?
标签: node.js console special-characters