hydrobyte / McJSON

A Delphi / Lazarus / C++Builder simple and small class for fast JSON parsing.
MIT License
58 stars 20 forks source link

Test #13 failed in Main branch (trunk rev. #94) #8

Closed totyaxy closed 1 year ago

totyaxy commented 1 year ago

My windows codepage:

** Command line: CHCP: Active code page: 852

** Power shell: Get-WinSystemLocale: LCID Name DisplayName 1038 hu-HU magyar (magyarországi)

** Wiki: https://en.wikipedia.org/wiki/Windows-1250 My country is Hungary.

hydrobyte commented 1 year ago

Hi,

Just a hint, these are better ways to check your CodePage using Lazarus:

Writeln('Console output codepage: ', GetTextCodePage(Output));
Writeln('System codepage: ', DefaultSystemCodePage);

I think Test13 will fail in the test13-Ansi.json part because this file content will be read using your CP (1250) and them compared to Utf8ToAnsi('ãçüö'), which was intended to be a CP 1252 string.

To check this diagnostic, please comment the following lines and run the test project again.

// M.LoadFromFile('test13-Ansi.json', false);
// Result := Result and (M['ansi'].AsString = Utf8ToAnsi('ãçüö'));

I think the UTF-8 parts from Test13 will be fine.

Also, I've been studying and to make this test CodePage agnostic I should use functions like CP1252ToUTF8() from LazUtils. Maybe I'll give it a try latter.

Regards,

totyaxy commented 1 year ago

Hi!

Result #1 (as I wrote before): Console output codepage: 852 System codepage: 1250

Result #2 All tests PASSED

Thank you!

totyaxy commented 1 year ago

Hi again!

I read what you wrote, then if I change this line: uses ... LConvEncoding,

Result := Result and (M['ansi'].AsString = Utf8ToAnsi('ãçüö')); to: Result := Result and (M['ansi'].AsString = UTF8ToCP1252('ãçüö'));

13 test passed!

BUT #1 test failed: [FAIL] Test 09: escapes

I think something conflict with the LConvEncoding unit.

totyaxy commented 1 year ago

...and YES!

Change this line in test #09: SRef := Utf8ToAnsi('aBçdç'); to SRef := UTF8ToCP1252('aBçdç');

then: All tests PASSED