Page 1 of 1

Show russian (Ansi) characters in Delphi XE

Posted: Tue 05 Feb 2019 15:42
by Moehre
I know that this is probably not a UniDAC problem at all, but perhaps someone had similar problems and found any solution for it:

I am porting a lot of Delphi7 programs to Delphi XE 10. The data is stored in an oracle RAC server 12c with GERMAN.GERMANY.AL32UTF8 charset.

In Delphi 7 I use ODAC and set the forms FONT.CHARSET value to 204 et voila: I can see the correct russian/cyrillic chars!

Up to know I was NOT able to do so in Delphi XE10! Changing the FONT.CHARSET property has no effect at all and a workaround I found with type Ansistring(1251) to convert the values has a little effect but the chars are still wrong.

Is there anyone in this forum who was able to display ANSI chars written with a non unicode software to database with Delphi XE correctly?

(Setting the Oracle NLS session params did not help either!)

Many thanks in advance

Re: Show russian (Ansi) characters in Delphi XE

Posted: Mon 11 Feb 2019 08:53
by MaximG
Please provide additional information about the issue. What operation mode are using : OCI Mode or Direct Mode ? Are you using UseUnicode property ( ) ?

Re: Show russian (Ansi) characters in Delphi XE

Posted: Mon 11 Feb 2019 10:10
by Moehre
That depends on the app: in 32 bit I use OCI, in 64 bit direct mode (because only 32 bit oracle clients are installed). I set unicode parameters to true, but in a test program I tried every combination on parameters und NLS_LANG settings with no success.

At the moment I think I will have to write a funtion which replaces the "wrong" characters with the correct (unicode) ones an vice versa till all programs are ported to XE.

The best way to do so would be an overwritten ".AsString" Field-Function which would automatically convert the (Ansi) string to unicode, but I don't know how to make that

Re: Show russian (Ansi) characters in Delphi XE

Posted: Wed 13 Feb 2019 15:53
by MaximG
The GERMAN.GERMANY.AL32UTF8 charset is not intended for storing russian/cyrillic char in the fields of the VARCHAR2 type. That is why in spite of the result you retrieved in Delphi 7, the method you use will not lead to the correct result in the later Delphi versions. Please try retrieving values of the required text fields without using any visual components (e.g. by assigning the value of one of these fields to a variable of the STRING type) and notify us of the results.

Re: Show russian (Ansi) characters in Delphi XE

Posted: Wed 13 Feb 2019 19:21
by Moehre
I tried some conversion using an AnsiChar variable with codepage assignment, f.e.

TRusStr = AnsiChar(1251);
MyRusStr: TRusStr;
ResStr: string;
MyRusStr := UniQuery1.Fields[0].AsString;
ResStr := MyRusStr; // this will do an internal conversion

Unfortunately nothing worked :(

It seems that I do have to write an internal conversion routine that replaces the resulting chars to the equivalent unicode ones. And to do so, it would be great, if I could alter the "AsString" function so that it will start this internal code-replacement automatically ... but I don't know how to do that - do I have to create a new TField component and assign this to a new UniQuery component?


Re: Show russian (Ansi) characters in Delphi XE

Posted: Fri 15 Feb 2019 16:16
by MaximG
The only potential way of the correct extraction of the previously saved text values in the encoding in question is the following one. Please try executing the data selection when encoding of your database and the one of the Windows system locale coincide. Besides, set the same value to the OraSession.Options.Charset property. Please note that this is a supposed solution for this task. For safe saving and loading charsets with the encoding you use, you need to use the Oracle DB Charset that supports it.