提交 26017a3c 编写于 作者: B baiy 提交者: ninecents

json 工具中 `unicode转中文` 功能 支持 `\Uxxxx` #62

上级 dfccb6e4
{
"name": "c-tool",
"version": "1.6.8",
"version": "1.6.9",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......
......@@ -55,7 +55,7 @@ const handleNoticeItems = ({code, data, info}) => {
}
const logError = (e) => {
// console.log(e)
console.log(e)
}
export default {
......
......@@ -21,6 +21,7 @@
import 'codemirror/addon/fold/brace-fold.js'
import 'codemirror/addon/fold/comment-fold.js'
import 'codemirror/addon/fold/foldgutter.css'
import Unicode from "./library/unicode"
export default {
components: {
......@@ -110,29 +111,12 @@
}
},
unicode2zh () {
let content = this.current.content
if (content) {
let newStr = ''
let t = 1
for (let i = 0; i < content.length; i += t) {
let str = content.charAt(i)
if (str === '\\' && 'u' === content.charAt(i + 1)) {
console.log(parseInt(parseInt(content.substr(i + 2, 4), 16).toString(10), 10))
newStr += String.fromCharCode(
parseInt(
parseInt(content.substr(i + 2, 4), 16).toString(10),
10
)
)
t = 6
} else {
t = 1
newStr += str
}
}
return newStr
}
return content
return Unicode.decode(
this.current.content.replace(/\\U[0-9a-fA-F]{4}/g,(item)=>{
// \Uxxxx=>\uxxxx
return item.replace("\\U","\\u");
})
)
},
zh2unicode () {
let content = this.current.content
......
......@@ -16,7 +16,7 @@ export default {
html_entity_16,
css_entitie
},
decode(str, type) {
decode(str, type = unicode_point_default) {
const errorListener = (item, callback) => {
try {
return callback && callback()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册