Open unbadfish opened 1 year ago
I have drawn a flowchart that shows how my commits work:
I hope it meet standards correctly.
The following test json file now can print non-BMP characters correctly. input
{
"1234bytes": "\u0043 h \u0079 Ҁ \u04a2 Ӯ \u9648 厚 \u5c27 𐐝 \ud852\udf62",
"appear": "C h y Ҁ Ң Ӯ 陈 厚 尧 𐐝 𤭢",
"hex": "\u0043 \u0068 \u0079 \u0480 \u04a2 \u04ee \u9648 \u539a \u5c27 \ud801\udc1d \ud852\udf62",
"feel": "\";\\),😊😁!",
"movement": "\u000b",
"name": "陈厚尧",
"school": "Beijing Institute of Technology(BIT)",
"id": 1120222936,
"found": 20230903,
"fix": 20230906,
"fomat": "yyyymmdd"
}
output:
{
"1234bytes": "C h y Ҁ Ң Ӯ 陈 厚 尧 \ud801\udc1d \ud852\udf62",
"appear": "C h y Ҁ Ң Ӯ 陈 厚 尧 \ud801\udc1d \ud852\udf62",
"hex": "C h y Ҁ Ң Ӯ 陈 厚 尧 \ud801\udc1d \ud852\udf62",
"feel": "\";\\),\ud83d\ude0a\ud83d\ude01!",
"movement": "\u000b",
"name": "陈厚尧",
"school": "Beijing Institute of Technology(BIT)",
"id": 1120222936,
"found": 20230903,
"fix": 20230906,
"fomat": "yyyymmdd"
}
This test file contains my public personal info to identify that who I am.
Support non-BMP (Basic Multilingual Plane) characters by printing them in
\u6789\uabcd
sequence.Background:
The standard RFC 8259 in https://datatracker.ietf.org/doc/html/rfc8259 (December 2017) clearly points out that...
, and here I copied some sentences from web...
Current behavior:
Whatever the length of utf-8 string is (2, 3, or 4), cJson copy the strings from storage memory to output buffer directly.
input:
current output (1.7.16):
It is worth stating that:
C h y
are 1 byte in utf-8; while the ones inҀ Ң Ӯ
are 2 bytes; in陈 厚 尧
, 3bytes; in𐐝 𤭢
, 4bytes.Expected behavior
If a character is not in Basic Multilingual Plane (BMP), the character should be represented as a 12-character sequence, using the UTF-16 surrogate pair, as the standard required.
Expected output:
Test info
The "current output (1.7.16)" is tested in this simple C-code
I beliveve that, this code can be run in nearly every platform whit no, or small change to the file-opening
_s
functions.My toolchain: Microsoft Visual Studio 2022 v17.7.3 MSVC v143 Win10 SDK 10.0.19041.0