瀏覽代碼

Added support for astral characters to charcode ops

n1474335 8 年之前
父節點
當前提交
15b83072bb
共有 4 個文件被更改,包括 27 次插入4 次删除
  1. 22 0
      src/core/Utils.js
  2. 1 1
      src/core/config/OperationConfig.js
  3. 3 2
      src/core/operations/ByteRepr.js
  4. 1 1
      src/core/operations/HTML.js

File diff suppressed because it is too large
+ 22 - 0
src/core/Utils.js


+ 1 - 1
src/core/config/OperationConfig.js

@@ -605,7 +605,7 @@ const OperationConfig = {
         args: []
     },
     "To Hexdump": {
-        description: "Creates a hexdump of the input data, displaying both the hexademinal values of each byte and an ASCII representation alongside.",
+        description: "Creates a hexdump of the input data, displaying both the hexadecimal values of each byte and an ASCII representation alongside.",
         run: Hexdump.runTo,
         highlight: Hexdump.highlightTo,
         highlightReverse: Hexdump.highlightFrom,

+ 3 - 2
src/core/operations/ByteRepr.js

@@ -108,8 +108,9 @@ const ByteRepr = {
             throw "Error: Base argument must be between 2 and 36";
         }
 
-        for (let i = 0; i < input.length; i++) {
-            ordinal = Utils.ord(input[i]);
+        const charcode = Utils.strToCharcode(input);
+        for (let i = 0; i < charcode.length; i++) {
+            ordinal = charcode[i];
 
             if (base === 16) {
                 if (ordinal < 256) padding = 2;

+ 1 - 1
src/core/operations/HTML.js

@@ -91,7 +91,7 @@ const HTML = {
             const bite = HTML._entityToByte[m[1]];
             if (bite) {
                 output += Utils.chr(bite);
-            } else if (!bite && m[1][0] === "#" && m[1].length > 1 && /^#\d{1,5}$/.test(m[1])) {
+            } else if (!bite && m[1][0] === "#" && m[1].length > 1 && /^#\d{1,6}$/.test(m[1])) {
                 // Numeric entity (e.g. &#10;)
                 const num = m[1].slice(1, m[1].length);
                 output += Utils.chr(parseInt(num, 10));

Some files were not shown because too many files changed in this diff