For any text in headers, you are best of with sticking to ISO-8859-1. For content, you have to mark that as UTF-8. Most likely, you want:
Content-Type: application/json; charset=utf-8
Depending on the content type, that charset may or may not also be marked within the content by the unicode mark at the beginning of the "file".
If the charset is not specified, most useragents will assume ISO-8859-1, according to HTTP spec. But some may infer other charsets, depending on things like the language header. Important here to note is that, while your request can specify any header you like, the server isn't really obligated to adhere to most of them. And the client will usually ignore all the headers you sent to the server and will only work on the headers that the server has sent back to you in the response.
For example, you set a 'Content-Type' request header. This is NOT a valid header. (Well, technically, it is valid HTTP, but it is ignored by servers because it's not in the spec as a client request header). The Content-Type header is a response header only, unless i seriously misremember the RFCs. The content type is set by the server and there is no in-header way to specify the charset the client wants.
For JSON, your best bet would probably to shove it through the JSON decoder library of your choice, hope it gets decoded correctly and then put it into your logger.
I haven't player with LWP::ConsoleLogger::*, but best bet is that it gets confused by a missing charset=utf-8 declaration or something. Most JSON modules on CPAN on the other hand make the mostly sensible choice of assuming that everything is UTF-8, because that's the same assumption JavaScript in most modern browsers would also make.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP::ConsoleLogger::Easy messes the console on (seemingly) unicode LWP response: is it a case of broken unicode?
by Corion (Patriarch) on Aug 24, 2023 at 15:08 UTC | |
|
Re^2: LWP::ConsoleLogger::Easy messes the console on (seemingly) unicode LWP response: is it a case of broken unicode?
by bliako (Abbot) on Aug 24, 2023 at 21:27 UTC | |
by cavac (Prior) on Aug 25, 2023 at 06:45 UTC | |
by NERDVANA (Priest) on Aug 25, 2023 at 21:12 UTC |