My Delphi program does not retrieve the right characters. SetThreadLocale for the entire Delphi application is the context of my problem. I am using Firebird 1.5 charset NONE database which contains WIN1257 data. I am using Delphi 10 Seattle IBX componentes to retrieve data from this database. Usually I use my program on Windows with one of the Baltic locale for non-Unicode programs. But sometimes I need to run my program on Windows with Russian locale (WIN1251 characterset).
And I am stuck with the following problem: database varchar field contains character ā
, which is retrieved in Delphi code (fieldname.asString) as \u0101
when the program is run with Baltic locale, but it is retrievied (fieldname.asString) as \u0432
when the program is run with Russian locale, but I need it to be displayed as \u0101
in Russian case as well.
I have tried to set all the connection parameters to TIBDatabase but failed to achieve my goal. So - now I have idea to do translation: I can detect that program is running under Russian locale and in that case I can apply special conversion function like MyConvert(fieldname.asString)
to convert \u0432
into \u0101
and something like this for all the characters.
The question is - is there such conversion function available and how to use it? What is the algorithm that determines the bijection \u0432
<-> \u0101
?
Migration to the unicode database is not my option.
Current question tries to solve the same core problem as SetThreadLocale for the entire Delphi application but with different approach. I have not managed to set thread locale for my application and therefore I decided to make character conversion and this question is - how to do it?
Added: https://en.wikipedia.org/wiki/Windows-1251 and https://en.wikipedia.org/wiki/Windows-1257 palettes show that a
has E2 position and this position in both palettes have different, but known Unicode characters, so the mapping is known and there is no single formula how to express it, it should be done character by character basis.