Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions JSON.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test it.
I had just saw a share of the method above from a post in ahkscript.
I learn much from the few lines (just in scope of while)! Thank you.

SetFormat, IntegerFast,% _FormatInteger
return """" . obj . """"
}
;// number
Expand Down Expand Up @@ -378,4 +377,4 @@ class JSON
return JSON.stringify(this, i)
}
}
}
}