javascript unicode与GBK2312(中文)编码转换方法
时间:2024-04-17 10:09:36
var GB2312UnicodeConverter = {
ToUnicode: function (str) {
return escape(str).toLocaleLowerCase().replace(/%u/gi, '\\u');
}
, ToGB2312: function (str) {
return unescape(str.replace(/\\u/gi, '%u'));
}
};
var str = '上海', unicode;
document.write(str + '<br/>');
unicode = GB2312UnicodeConverter.ToUnicode(str);
document.write('汉字转换为Unicode代码:' + unicode + '<br/><br/>');
document.write('Unicode代码转换为汉字:' + GB2312UnicodeConverter.ToGB2312(unicode));
标签:javascript,unicode,GBK2312
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python训练数据时打乱训练数据与标签的两种方法小结
2021-11-17 11:15:12
关于使用python反编译apk签名出包的问题
2022-12-19 19:39:04
详解python上传文件和字符到PHP服务器
2023-10-15 19:02:12
Python 制作查询商品历史价格的小工具
2021-10-13 06:03:16
![](https://img.aspxhome.com/file/2023/3/84883_0s.png)
查询字符串中包含特殊字符的问题
2009-01-09 13:13:00
提高JavaScript执行效率的23个实用技巧
2023-08-15 18:38:12
InnoDB解决幻读的方法详解
2024-01-15 13:50:53
![](https://img.aspxhome.com/file/2023/8/122888_0s.jpg)
创建动态MSSQL数据库表
2024-01-19 03:04:08
Vue Cli与BootStrap结合实现表格分页功能
2024-05-09 15:21:44
python3实现磁盘空间监控
2023-07-09 14:12:49
Python栈算法的实现与简单应用示例
2023-11-16 23:18:30
![](https://img.aspxhome.com/file/2023/2/105092_0s.png)
Vue 2.0 服务端渲染入门介绍
2023-07-02 16:58:52
详解python 拆包可迭代数据如tuple, list
2022-01-08 19:28:43
Python读取txt文件数据的方法(用于接口自动化参数化数据)
2023-12-28 03:21:52
![](https://img.aspxhome.com/file/2023/9/66419_0s.png)
MySQL创建数据库并支持中文字符的操作方法
2024-01-27 16:09:45
![](https://img.aspxhome.com/file/2023/7/124067_0s.png)
python使用SMTP发送qq或sina邮件
2021-03-08 01:06:55
![](https://img.aspxhome.com/file/2023/4/78454_0s.png)
基于Python的OCR实现示例
2021-03-05 20:58:43
JS正则(RegExp)判断文本框中是否包含特殊符号
2023-05-12 18:18:55
python smtplib模块发送SSL/TLS安全邮件实例
2023-12-18 01:53:09
盘点Python 爬虫中的常见加密算法
2023-07-19 05:05:22
![](https://img.aspxhome.com/file/2023/5/124245_0s.jpg)