Two unicode code-points when using json_write()?

418 Views Asked by At

When using boost::property_tree::write_json() to write a JSON file, all unicode characters will be represented as two "/u"-code points.

  • So ä will become \u00C3\u00A4.

My problem is, that I am generating a JSON file which will be read via JQuery to be shown in a web page. In that case, this pair will be shown as two separated unicode symbols.

  • So ä looks like ä

Is there a way to configure the output encoding to get a single Utf16 code point? Or is there a way to tell jQuery to use both code-points as one?

Also, why is ä becoming \u00C3\u00A4 instead of \u00E4? I really don't get it.

Thanks for help!

1

There are 1 best solutions below

0
On

That's because it's encoded as "UTF-8", if the output comes out wrong like that, it's either because it's been encoded twice, or because it's not being "understood" as UTF-8. Which is probably because the web-page is not correctly set up to say "use UTF-8". Your header on the page will need to have Content-Type: text/html; charset=utf-8 or something along those lines.