문제

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!

dd

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top