delphi - Encodeing results are not working -


i have program written in delphi 4 , trying convert delphi xe10. 1 part not understand this.

    cmd[0] := 2;                   // number of equipment talk     cmd[1] := 22;                  // device address     cmd[2] := 0;     mresults.lines.add('reciving...');     refresh();      srlen := high(recbuff);                                      ret := gplisten(@cmd, @srlen, @recbuff);              // gets returned value     if checkret('gplisten', (ret , $ff), csbuf) = 0      begin         recbuff[srlen] := chr(0);                            // ??         mresults.lines.add(recbuff);               // returned          //csbuf := format('????', [srlen]); ////?some error??     end; 

the issue recbuff (recbuff:array[0..9999] of char;) starts off full of #0 so:

enter image description here

but

ret := gplisten(@cmd, @srlen, @recbuff);  

is ran recbuff looks this:

enter image description here alot of japan char. how encode onto memopad correctly.

try changing

recbuff:array[0..9999] of char; 

to

recbuff:array[0..9999] of ansichar; 

and see if works. may prompt changes other places in code.

in delphi 10, "char" 2-byte entity (16 bit character, unicode) opposed delphi 4, 1-byte entity (8 bit character, ansi). common format both compilers "ansichar", 8-bit character.

you'll have issues string variables filled 16-bit characters , not 8-bit characters.

also - read the absolute minimum every software developer absolutely, positively must know unicode , character sets (no excuses!) before going further in conversion.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -