Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have my own D6 pas library with crypto functions.
Today I tried to use it under XE3, and I found many bugs in it because of unicode.
I tried to port to AnsiString, but I failed on chr(nnn) which was 8 bit limited under Delphi6.
I'm trying to explain the problem:
Str := chr(hchar);
AStr := Str;
Str - string; AStr - ansistring.
When the hchar was 216 (diamater), then AStr changed to "O", what is Ascii 79...
And I lost the original value at this moment.
Is there any function for Ansi Chr? For example: "AChr(xxxx)"
Or I need to change my code to not use Strings in the inner section, only bytes and later convert these bytes to AnsiString?
Thanks for any suggestion, help, info!
–
You can write AnsiChar(SomeOrdinalValue) to make an AnsiChar with a specific ordinal. So your code should be:
AStr := AnsiChar(hchar);
The problem with the code in the question is that you converted to UTF-16 and back.
It would seem to me that strings are the wrong type for your crypto code. Use a byte array, TBytes.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.