Prechádzať zdrojové kódy

增加utf16编解码功能

zxlie 6 rokov pred
rodič
commit
8dc6628494

+ 6 - 17
apps/en-decode/endecode-lib.js

@@ -223,23 +223,11 @@ module.exports = (() => {
      * @return {String}
      */
     let _utf16to8 = function (str) {
-        let out, i, len, c;
-        out = "";
-        len = str.length;
-        for (i = 0; i < len; i++) {
-            c = str.charCodeAt(i);
-            if ((c >= 0x0001) && (c <= 0x007F)) {
-                out += str.charAt(i);
-            } else if (c > 0x07FF) {
-                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
-                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
-                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
-            } else {
-                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
-                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
-            }
-        }
-        return out;
+        return str.replace(/\\x/g,'%');
+    };
+
+    let _utf8to16 = function(str){
+        return str.replace(/%/g,'\\x');
     };
 
     /**
@@ -259,6 +247,7 @@ module.exports = (() => {
         utf8Encode: _utf8Encode,
         utf8Decode: _utf8Decode,
         utf16to8: _utf16to8,
+        utf8to16: _utf8to16,
         md5: md5
     };
 })();

+ 3 - 0
apps/en-decode/index.css

@@ -8,4 +8,7 @@
 }
 .ui-ml-05 {
     margin-left: 5px;
+}
+.x-ps {
+    color:#bbb;
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
apps/en-decode/index.html


+ 6 - 0
apps/en-decode/index.js

@@ -42,6 +42,12 @@ new Vue({
                 } else if (this.selectedType === 'utf8Decode') {
 
                     this.resultContent = decodeURIComponent(this.sourceContent);
+                } else if (this.selectedType === 'utf16Encode') {
+
+                    this.resultContent = tools.utf8to16(encodeURIComponent(this.sourceContent));
+                } else if (this.selectedType === 'utf16Decode') {
+
+                    this.resultContent = decodeURIComponent(tools.utf16to8(this.sourceContent));
                 } else if (this.selectedType === 'base64Encode') {
 
                     this.resultContent = tools.base64Encode(tools.utf8Encode(this.sourceContent));

+ 2 - 0
apps/html2markdown/index.css

@@ -22,6 +22,8 @@
 }
 .x-preview {
     height: auto;
+    word-break: break-all;
+    white-space: pre-wrap;
 }
 .x-xdemo,.x-switch {
     margin-left: 30px;

+ 1 - 1
apps/manifest.json

@@ -1,6 +1,6 @@
 {
   "name": "WEB前端助手(FeHelper)",
-  "version": "2018.11.2222",
+  "version": "2018.12.0319",
   "manifest_version": 2,
   "default_locale": "zh_CN",
   "description": "FE助手:包括JSON格式化、二维码生成与解码、信息编解码、代码压缩、美化、页面取色、Markdown与HTML互转、网页滚动截屏、正则表达式、时间转换工具、编码规范检测、页面性能检测、Ajax接口调试、密码生成器、JSON比对工具、网页编码设置、便签笔记",

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov