in reply to JSON character encoding
JSON, being a data exchange format, does not have a concept of “character encodings.” Its purpose is to allow structured data to be correctly transmitted from place to place, particularly in contexts where HTML and the use of “web servers” is assumed. (Secondarily, it was intended to be friendly to JavaScript, so that you can use Global.eval(), as in fact people did do in younger and more-innocent days.)
Anytime you display or “print” a received data-stream, character encoding does play a part in the process that is used to create what you see. Most of the time, UTF encoding is assumed, and the software in question watches-out for the telltale byte sequences in order to “be helpful” and “do the right thing.” This can get in the way, however, when you are debugging. Sometimes the best thing to do is to dump the relevant parts in hexadecimal:
00000000 50 65 72 6c 20 70 72 6f 67 72 61 6d 0a |Perl program.|
When you subsequently display the data “for real,” if you know that the data is UTF-encoded, you must somehow tell this to the final rendering device. In an HTML data-stream, for instance, this is done by means of a header. The necessity to use things like #1234 depends entirely on what the device has been told to expect. (Don’t assume that it will “assume.”)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: JSON character encoding
by Your Mother (Archbishop) on May 30, 2017 at 14:53 UTC | |
by Anonymous Monk on May 30, 2017 at 15:17 UTC | |
by locked_user sundialsvc4 (Abbot) on May 30, 2017 at 17:28 UTC | |
by Anonymous Monk on May 31, 2017 at 07:51 UTC | |
by RonW (Parson) on May 31, 2017 at 22:42 UTC |