make folly::toJson retain non-ascii chars if encode_non_ascii is disabled
Summary: folly::toJson as demonstrated by the test cases was wrongly encoding utf8 strings. specifically, a utf8 char made up of x bytes was encodeded into x unicode chars. for example, the char: \u2665 which is made of 3 bytes: \xe2\x99\xa5 was encoded correctly when using encode_non_ascii = true: "\u2665" but when encode_non_ascii = false, the json value was wrongly set as: "\u00e2\u0099\u00a5" because we use an signed char that wrongly detects non-readable chars with ascii value > 127 as control chars with ascii value < 32 (\t, \n, etc.) Test Plan: run the test Reviewed By: delong.j@fb.com FB internal diff: D612782
Showing
Please register or sign in to comment