简体   繁体   English

在javascript中将文本字符串转换为unicode字符

[英]Convert text string to unicode characters in javascript

Lets say I have a text string such as 'hey' and I have a unicode alphabet like Latin Extended-A from wikipedia .假设我有一个文本字符串,例如 'hey' 并且我有一个 unicode 字母表,例如来自wikipedia 的Latin Extended-A 。 How can I map capital A to its similar A in the unicode one.如何将大写 A 映射到 unicode 中的类似 A。 I think I would need to split the english string and have it in the array but then how would it know which letter that is?我想我需要拆分英文字符串并将其放入数组中,但是它怎么知道是哪个字母呢? Is there a library for this?有图书馆吗?

I believe the answer to this question is here: How do I convert special UTF-8 chars to their iso-8859-1 equivalent using javascript?我相信这个问题的答案在这里: 如何使用 javascript 将特殊的 UTF-8 字符转换为它们的 iso-8859-1 等效字符?

so essentially:所以基本上:

decodeURIComponent(escape(utfstring)) decodeURIComponent(escape(utfstring))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM