Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem of incorrect transcoding in Chinese #803

Closed
zhbgs2000 opened this issue Jul 3, 2018 · 7 comments
Closed

The problem of incorrect transcoding in Chinese #803

zhbgs2000 opened this issue Jul 3, 2018 · 7 comments

Comments

@zhbgs2000
Copy link

zhbgs2000 commented Jul 3, 2018

	Json::Value json_temp; 
	json_temp["name"]	= "中国234";
	string name			= json_temp["name"].asString();
	Json::Value root;  		
	root["key_number"]	= Json::Value(12345);					
	root["key_boolean"] = Json::Value(false);					
	root["key_double"]	= Json::Value(12.345);					
	root["key_object"]	= json_temp;													
						
	Json::StreamWriterBuilder builder;
	builder["commentStyle"] = "None";
	builder["indentation"] = "";
	//string s		= fast_writer.write(root);
	//string_t s	= utility::conversions::to_string_t(fast_writer.write(root));
	//string result = fast_writer.write(root);
	string result = Json::writeString(builder, root);
	cout <<"name: "<< name << endl;	//is ok
	cout <<"result: "<< result << endl; //no ok
       ......

print info:
name: 中国234
result: {"key_boolean":false,"key_double":12.345000000000001,"key_number":12345,"key_object":{"name":"\u0590\u067a234"}}

jsoncpp version:1.8.4
ide: visual studio 2017 c++
The value of the variable name is displayed in Chinese, and the Chinese contained in variable result cannot be displayed properly.

@robot0x
Copy link

robot0x commented Jul 11, 2018

i encounter the same problem, anyone help!!

@robot0x
Copy link

robot0x commented Jul 11, 2018

it seems writeString function transform chinese character to unicode after see source code.

@zhbgs2000
Copy link
Author

use jsoncpp version 1.8.3 is ok

@cdunn2001
Copy link
Contributor

See #687. We need someone to add a configuration setting to determine whether to assume the internal representation is UTF-8.

@maxguru
Copy link

maxguru commented Apr 5, 2020

Is there any progress on this? As far as I can tell there is no way to tell jsoncpp to not escape UTF-8 characters with \u with the post 1.8.3 versions. It would be really nice to have this feature.

@dota17
Copy link
Member

dota17 commented Apr 7, 2020

@maxguru
You can try the new feature - emitUTF8, which is merged from #1045 .

@maxguru
Copy link

maxguru commented Apr 7, 2020

@dota17 nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants