在javascript中将文本转换为Unicode [英] Converting text to Unicode in javascript
本文介绍了在javascript中将文本转换为Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
function showUnicode()
{
var text = prompt( 'Enter the wanted text', 'Unicode' ),
unicode = 0,
ntext,
temp,
i = 0
;
// got the text now transform it in unicode
for(i; i < text.length; i++)
{
unicode += text.charCodeAt(i)
}
// now do an alert
alert( 'Here is the unicode:\n' + unicode + '\nof:\n' + text )
}
感谢您的想法初始化unicode但现在unicode变量获取最后一个字符的Unicode,为什么呢?
Thanks for the idea to initialize unicode but now unicode variable gets the Unicode of the last character, why does it?
推荐答案
这篇关于在javascript中将文本转换为Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文