sp0987 0 Posted June 25 Hi, I am trying to create a .JSON file in Delphi 11 64-bit. While writing sample data to .json file , the   character was weird in 64-bit. In 32-bit version , it was like "u00A0" and when coming to 64-bit version it was like "u=<68" and sometimes "u3<78". When I parse this resulted json file in .JS files , it throws an error like "invalid JSON". Attached are samples from 32-bit and 64-bit. Please suggest. 32-bit.json 64-bit.json Share this post Link to post
Lajos Juhász 270 Posted June 25 A sample application that we can compile as a 64 and 32 bit would help us to help you. We can only suggest that you make improvements in your code. Share this post Link to post
Virgo 18 Posted June 25 Are added samples supposed to be valid json? Because they both are missing end. Which raises a question, how the json was generated. Share this post Link to post
sp0987 0 Posted June 25 It was just a part of json file, not the whole thing. Share this post Link to post
Die Holländer 33 Posted June 25 U+1618 was added in Unicode version 3.0 in 1999. It belongs to the block Unified Canadian Aboriginal Syllabics in the Basic Multilingual Plane. The word that U+1618 forms with similar adjacent characters prevents a line break inside it. >"filled with\u1618MVR\u1618information" Share this post Link to post
sp0987 0 Posted June 25 Am having issue with "u3<78" . Instead of "u1618", am getting "u3<78" in some areas. When we see the 32-bit , it was 'u00A0' all over. Share this post Link to post
Die Holländer 33 Posted June 25 1 hour ago, Lajos Juhász said: A sample application that we can compile as a 64 and 32 bit would help us to help you. We can only suggest that you make improvements in your code. Share this post Link to post
sp0987 0 Posted June 25 (edited) Attaching a sample project. The project will create a json file, which when we try to use in javascript reults in error "invalid Json". can be run in bot 32-bit and 64-bit with few changes. The changes were mentioned in the respected .pas files as comments. TestJson.7z Edited June 25 by sp0987 Share this post Link to post
Stefan Glienke 1974 Posted June 25 Your assembly code of Int2Hex for 64bit is wrong - c is passed in RCX. Share this post Link to post
Brian Evans 100 Posted June 26 (edited) 9 hours ago, sp0987 said: Am sorry i didn't get you In 64bit RAX does not contain the first parameter of your Int2Hex function, RCX does. Looks like there are also other problems with the 64 bit ASM code like where the return value is stored: it should end up in RAX, Ref: Using Inline Assembly Code - RAD Studio (embarcadero.com) Quote The first four parameters to inline assembler functions are passed via RCX, RDX, R8, and R9 respectively, except for floating-point arguments which use XMMO, XMM1, XMM2, XMM3. The math coprocessor is not normally used from x64 code. Registers used for function parameters can be modified freely. Ref: Assembly Procedures and Functions - RAD Studio (embarcadero.com) Quote 64-bit Values 8 bytes or less in size are return in RAX. Real values are returned in XMM0. Other types are returned by a reference whose pointer value resides in RAX whose memory is allocated by the calling routine. Edited June 26 by Brian Evans Share this post Link to post
Stefan Glienke 1974 Posted June 26 FWIW the assembly implementation of that function is pointless given you can do it in a way more readable way - also performance cannot be a reason given the following call to mem_write causes a temporary heap allocation to convert your hex_code variable into an AnsiString. Quickly slapped together (anyone who wants to further optimize this - be my guest, i cba right now): type hex_code = Array [1 .. 4] of AnsiChar; function Int2Hex(c: Word): hex_code; const HexChars: array[0..15] of AnsiChar = '0123456789ABCDEF'; var i: NativeUInt; begin i := c; Result[4] := HexChars[i and $0F]; i := i shr 4; Result[3] := HexChars[i and $0F]; i := i shr 4; Result[2] := HexChars[i and $0F]; i := i shr 4; Result[1] := HexChars[i and $0F]; end; and then instead of mem_write with AnsiString as the first argument use one that writes 4 bytes at once. 1 Share this post Link to post
Attila Kovacs 625 Posted June 26 Quote CBA is an acronym that means can't be arsed, meaning, essentially, that a person can't be bothered to find the energy or willingness to do something. It's used in England, Australia, and New Zealand more than it is in the US. Arse is a British slang version of ass. 1 Share this post Link to post
Stefan Glienke 1974 Posted June 26 Can't be asked - I am using the sfw (safe for work) version 😇 1 1 Share this post Link to post
Die Holländer 33 Posted June 26 if S[I] in [WideChar(' ') .. WideChar('~')] Then mem_char(AnsiChar(S[I]), Buf) else Begin mem_char('\', Buf); mem_char('u', Buf); mem_write(IntToHex(ord(S[I]),4), Buf); end; Share this post Link to post