怎么才能实现utf8编码呢?

How can we achieve utf8 encoding?

我们如何使用 utf8bytes=unescape(encodeURIComponent(unicodecharacters))

实现 utf-8 编码

据我所知,encodeURIComponent 将字符串转换为 UTF-8 字符编码,如果是这种情况,那么我们使用 unescape 来获得 UTF-8 编码的原因。 Unescape 将从 hexadecimal encoding return ASCII 字符串,因此它将解码字符串。我已经提到了这个 http://xkr.us/articles/javascript/encode-compare/

没有。在 JavaScript 中,一个 String is a counted sequence of UTF-16 code units. When you want a different character encoding, you use a different data type, such as Buffer or UInt8Array. And, so, no Unescape does not return an ASCII string; though it might return a string with only C0 Controls and Basic Latin 代码点。

(但是,是的,将非 ASCII 放在 URL 中(在协议、域名和任何端口、密码和用户名之后)的非常常见的约定是对一些字节进行 % 编码,并且将哪些字节放入 URL 中的非常常见的约定是使用 UTF-8 编码文本。最终,由服务器来解释。)