js 将汉字转换为GB2312格式的编码

版权声明:汝之秀,唔何日能及也。 https://blog.csdn.net/Lpandeng/article/details/80224342
  • 引入js: encodeToGb2312.js下载地址
  • 引用此js后,调用 encodeToGb2312(str)即可。

eg

<input id="q" type="text" />

<input id="button" type="button" value="搜索" />

给以上输入框绑定点击事件,在点击事件中:console.log(encodeToGb2312(str)) (str)是输入框的汉字。

猜你喜欢

转载自blog.csdn.net/Lpandeng/article/details/80224342