[Lazarus] [fpc-pascal] Tests results of several pascal based JSON parsers

Michael Van Canneyt michael at freepascal.org
Fri Aug 30 12:48:23 CEST 2019



On Fri, 30 Aug 2019, Anthony Walter via lazarus wrote:

> Michael,
>
> Can you tell me why the second half (N.Items[1].AsUnicodeString) this test
> fails? This is the part that decodes "bank teller \u00Ae ".


The test fails on "Joe®Schmoe", not on "bank teller \u00Ae ".

If you WriteLn the UnicodeChars string to console, it shows:

{ "name": "Joe®Schmoe", "occupation": "bank teller \u00Ae " }

(notice the  in front of ®)

This is because your string is encoded wrong in the binary.

Adding

{$codepage UTF8}

Before the uses clause makes your test print 'TRUE'.

Because I work on Linux, I also had to add the "cwstring" unit to the uses clause.

Michael.


More information about the lazarus mailing list