Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: [py 2.7] JSON and UTF-8

28 views
Skip to first unread message

dieter

unread,
Sep 30, 2016, 2:33:37 AM9/30/16
to
Gilmeh Serda <gilmeh...@nothing.here.invalid> writes:

> Is there something that can be done when writing JSON using its dump/
> dumps feature so, e.g. Cyrillic text will show up correctly in a text
> editor afterwards?
> ...
> The 'template.json' contains this:
>
> {
> "test": "øæßþåнайтеĦŒŒ®®®"
> }
>
> What the json module outputs to the 'output.json' file is:
>
> {"test": "\u00f8\u00e6\u00df\u00fe\u00e5\u043d\u0430\u0439\u0442\u0435
> \u0126\u0152\u0152\u00ae\u00ae\u00ae"}
>
> But I would really like to be able to read that.

The "dumps" function has a parameter which allows the use
of unicode (instead of ascii encoded) strings.
Likely, using this parameter will solve your problem.


I have found out that some browsers have problems with some
unicode characters. Maybe, this is one reason to have
ascii encoded strings the default for "dumps".

Lawrence D’Oliveiro

unread,
Sep 30, 2016, 7:56:29 PM9/30/16
to
On Friday, September 30, 2016 at 7:33:37 PM UTC+13, dieter wrote:
> I have found out that some browsers have problems with some
> unicode characters.

Which browsers? More likely that was an OS problem.
0 new messages