Skip to content

Dump JSON containing multibyte characters #1999

Description

I want to be able to dump JSON containing multibyte characters.

My std::string contains 3 characters (or glyphs) in UTF-8: Año.

In UTF-8, 'ñ' is represented as two bytes: \xC3 \xB1.

So, my string contains 4 bytes: [\x41, \xC3, \xB1, \x6F]

The problem appears when I get the dump of the JSON containing the mentioned string. It seems that the library dumps each byte as a character in Latin1: "{"text": "Año"}"

I'm expecting the following string in the dump: "{"text": "A\u00f1o"}"

But I read in other issues of the library that it assumes all strings are UTF-8. Shouldn't this mean that it must be able to know that the "\xC3 \xB1" bytes represent a single character? Am I missing something here?

I always code in Linux + Emacs + GCC, but in this project I need to use Visual Studio 2017.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions