From 6ac3a1f64cc0004c5db1923481a402cbfbbb9449 Mon Sep 17 00:00:00 2001 From: RobertL Date: Tue, 8 Jul 2014 20:18:52 +0800 Subject: [PATCH] Update JSON.ahk Get the character code derectly! Replace "0x" to "\u". Much faster I think! I don't know, how to get NumberType of SetFormat for restore later? I will ask in fourm. --- JSON.ahk | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/JSON.ahk b/JSON.ahk index f423e8b..53c6d4a 100644 --- a/JSON.ahk +++ b/JSON.ahk @@ -258,13 +258,12 @@ class JSON for k, v in esc_char StringReplace, obj, obj, % k, % v, A - while RegExMatch(obj, "[^\x20-\x7e]", ch) { - ustr := Asc(ch), esc_ch := "\u", n := 12 - while (n >= 0) - esc_ch .= Chr((x:=(ustr>>n) & 15) + (x<10 ? 48 : 55)) - , n -= 4 - StringReplace, obj, obj, % ch, % esc_ch, A - } + _FormatInteger:=A_FormatInteger + ;I don't know, how to get NumberType of SetFormat for restore later? + SetFormat, IntegerFast, hex + while RegExMatch(obj, "[^\x20-\x7e]", ch) + StringReplace, obj, obj, % ch, % "\u" SubStr(Asc(ch),3), A + SetFormat, IntegerFast,% _FormatInteger return """" . obj . """" } ;// number @@ -378,4 +377,4 @@ class JSON return JSON.stringify(this, i) } } -} \ No newline at end of file +}