问题描述
我想从其他网站加载一些文本,内容是GBK编码的,但是我的网站是UTF8。有没有可以转换这些GBK文本转换成UTF8显示?
由于某些原因,我只能使用Javascript。
有一个javascript可以在gbk和unicode之间进行转换: 将所有21886 gbk中文字符映射到unicode您可以下载,包含它并使用:
unicode to gbk:
或gbk to unicode:
我测试了它。在我的网站上工作得很好:zhuhaiyang.sinaapp.com/base64/index.html
使用纯javascript做base64。。。
I want to load some text from other site wich the content is GBK encoded, but my site is UTF8.
Is there anyway by which I can convert these GBK text into UTF8 for display ?
For some reasons I can only use Javascript for this.
http://www.1kjs.com/lib/widget/gbk/
There is a javascript to convert between gbk and unicode: which maps all the 21886 gbk Chinese chars to unicode
You can simply download the javascript file , include it and using :
unicode to gbk:
or gbk to unicode:
I tested it. It's working well on my web : zhuhaiyang.sinaapp.com/base64/index.html
which do base64 ency using pure javascript.
这篇关于如何使用纯JavaScript将GBK转换为UTF8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!