{
   "description" : "A quick utility function for decoding UTF-8 characters in %hex codes (such as for web URLs). Save the code into a .sc file in your Extensions/ directory, recompile, and then:\r\n\r\n\"%E5%A4%A7%E5%AE%B6%E5%A5%BD\".decodeHex;\r\n-> 大家好\r\n\r\nThis probably works only for UTF-8. SC can save the individual bytes of Unicode characters into String objects, and the IDE will print UTF-8 code points correctly, but there is no way to switch the IDE to other Unicode variants.",
   "ancestor_list" : [],
   "author" : "jamshark70",
   "name" : "Decode %hex encoded characters",
   "code" : "+ String {\r\n\tdecodeHex {\r\n\t\tvar new = String.new, stream = CollStream(this), ch, int;\r\n\t\twhile {\r\n\t\t\tch = stream.next;\r\n\t\t\tch.notNil\r\n\t\t} {\r\n\t\t\tif(ch == $%) {\r\n\t\t\t\tch = stream.next;\r\n\t\t\t\tif(ch.notNil) {\r\n\t\t\t\t\tint = ch.digit << 4;\r\n\t\t\t\t} {\r\n\t\t\t\t\t// If the string ends with %, then 'ch' after that is nil\r\n\t\t\t\t\t// so we can just append the %\r\n\t\t\t\t\t^new.add($%);\r\n\t\t\t\t};\r\n\t\t\t\tch = stream.next;\r\n\t\t\t\tif(ch.notNil) {\r\n\t\t\t\t\tch = (int + ch.digit).asAscii;\r\n\t\t\t\t} {\r\n\t\t\t\t\t// If we got this far, we know there was one (only one) char after %\r\n\t\t\t\t\t// so add them both\r\n\t\t\t\t\t^new.add($%).add(this.last);\r\n\t\t\t\t};\r\n\t\t\t};\r\n\t\t\tnew = new.add(ch);\r\n\t\t};\r\n\t\t^new\r\n\t}\r\n}",
   "is_private" : null,
   "id" : "1-5aM",
   "labels" : [
      "utility",
      "string",
      "hex"
   ]
}
