Home > Web Front-end > JS Tutorial > js tool to convert characters to UTF-8 characters_javascript skills

js tool to convert characters to UTF-8 characters_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:24:57
Original
1658 people have browsed it

在下面的文本框中输入中文文字,按“转化”,即可将其转化为UTF-8字符。
再按“还原”,即可将其还原为简体中文。

<script> var mode="zhuan"; function encode(obj,btn){ if(mode=="zhuan"){ obj.value=obj.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")}); btn.value="还原"; mode="huan"; }else{ obj.value=unescape(obj.value.replace(/&#x/g,'%u').replace(/;/g,'')); btn.value="转化"; mode="zhuan"; } } </script>


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Problems React encounters when using utf-8
From 1970-01-01 08:00:00
0
0
0
How to create utf-8 files in python?
From 1970-01-01 08:00:00
0
0
0
Always use UTF-8 encoding
From 1970-01-01 08:00:00
0
0
0
Full UTF-8
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template