Skip to content

UTF-8/Unicode error #982

Description

@frank83413

I have some problems with parsing UTF-8
Here is my code

#include <iostream>
#include <string.h> 
#include "nlohmann/json.hpp"
using json = nlohmann::json;

int main()
{
	json j1 = "{\"name\":\"\\u6211\"}"_json;
	json j2 = json::parse(R"({ "name" : "\u6211" })");
        std::cout << j1.dump() << std::endl;
	std::cout << j2.dump() << std::endl;
	system("pause");
	return 0;
}

I think I should get output like :

{"name":"我"}
{"name":"我"}

but I only get:

{"name":"?

If I do auto temp = j1["name"].get<std::string>(); temp will have Invalid character in string.

Are there anyone could help me to fix it?

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