GithubHelp home page GithubHelp logo

Shorteners self-test result about mcjson HOT 7 CLOSED

hydrobyte avatar hydrobyte commented on July 17, 2024
Shorteners self-test result

from mcjson.

Comments (7)

hydrobyte avatar hydrobyte commented on July 17, 2024

Hi,

Please, test the "main" branch for decimal separator awareness and other fixes. See InternalFloatToStr and InternalStrToFloat.

The "Shorteners" branch will be merged to "main" soon.

Regards,

from mcjson.

totyaxy avatar totyaxy commented on July 17, 2024

I thought the shortener was a newer version. The trunk version with "," or "." only 1 test failed (save and load using files).

from mcjson.

hydrobyte avatar hydrobyte commented on July 17, 2024

Nice.
Could you debug it and report why this test failed?
Here I have two Windows PCs with Lazarus 2.2.0 and 2.3.0 and both have zero failures.

from mcjson.

totyaxy avatar totyaxy commented on July 17, 2024

Hi, yes.

If any of them allowed then reasult test failed:

// load a Ansi file (especifying it)
M.LoadFromFile('test13-Ansi.json', false);
Result := Result and (M['ansi'].AsString = 'ăçüö');

// load a UTF-8 file
M.LoadFromFile('test13-UTF8.json');
Result := Result and (M['utf8'].AsString = 'ăçüö');

But not a surprise, as I see {$mode delphi} , and {$codepage cp1252} on the file header.

If I see these file with notepad++

  1. test13-Ansi.json (force cp1252 codepage because I see garbage otherwise):
    {"ansi":"ãçüö"} (it's different as you see)

  2. test13-UTF8.json (auto UTF8 detected correctly):
    {"utf8":"ãçüö"} (it's different too as you see)

Then I try to rewrite the "ă" to "ã" in the source, then I got message from the Lazarus: "save file cp1250 loose characters.."

So this is character encoding problem.

from mcjson.

hydrobyte avatar hydrobyte commented on July 17, 2024

Hi,

  1. "test13-Ansi.json" is a ANSI file with CP-1252 characters. Here in my Notepad++ (via menu Encoding > Character sets > Western European > Windows-1252) I can see "{"ansi":"ãçüö"}" as expected.

  2. I've set {$codepage cp1252} in PrjTestMcJSON.lpr because the .lpr file is not encoded in UTF-8. It opens correctly, it compiles and run OK.

  3. Into your description I just see "ãçüö". There is no "ă" (items 1 and 2).

I think this error is related with your Windows (System) Codepage, that might be different from 1252. I just don't know why {$codepage cp1252} failed in order to prevent this CodePage misleading.

I'll explore changing my source code files to UTF-8, but I think this will broke Delphi (old versions) and Lazarus/FPC compatibility. I'll try changing just the .lpr file first to UTF-8 and improve Test13.

On the other hand, I think this error can't stop you from using McJSON if you work with .json files encoded in UTF-8.

Thanks for sharing. Stay tuned to next commits.

Regards,

from mcjson.

totyaxy avatar totyaxy commented on July 17, 2024

Hi, I stayed, with the latest revision 94, the result of test 13 is still failed (Laz 2.2.4 and Laz 2.3.0 both same results)

from mcjson.

hydrobyte avatar hydrobyte commented on July 17, 2024

Hi,

I was revising Lazarus support to UTF-8, comparing it to Delphi pre-Unicode, and I think it is expected that Test13 fails with a Windows CodePage different from 1252.

I'll close this thread because it is in the wrong branch.

Please, create a new Issue within main branch and report your Windows CodePage.

Regards,

from mcjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.