Show russian (Ansi) characters in Delphi XE

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Moehre
Posts: 42
Joined: Fri 11 Nov 2005 11:37

Show russian (Ansi) characters in Delphi XE

Post by Moehre » Tue 05 Feb 2019 15:42

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
Detlev

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Show russian (Ansi) characters in Delphi XE

Post by MaximG » Mon 11 Feb 2019 08:53

Please provide additional information about the issue. What operation mode are using : OCI Mode or Direct Mode ? Are you using UseUnicode property ( https://www.devart.com/unidac/docs/using-oracle.htm ) ?

Moehre
Posts: 42
Joined: Fri 11 Nov 2005 11:37

Re: Show russian (Ansi) characters in Delphi XE

Post by Moehre » Mon 11 Feb 2019 10:10

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

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Show russian (Ansi) characters in Delphi XE

Post by MaximG » Wed 13 Feb 2019 15:53

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.

Moehre
Posts: 42
Joined: Fri 11 Nov 2005 11:37

Re: Show russian (Ansi) characters in Delphi XE

Post by Moehre » Wed 13 Feb 2019 19:21

I tried some conversion using an AnsiChar variable with codepage assignment, f.e.

type
TRusStr = AnsiChar(1251);
...
var
MyRusStr: TRusStr;
ResStr: string;
begin
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?

Greetings
Detlev

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Show russian (Ansi) characters in Delphi XE

Post by MaximG » Fri 15 Feb 2019 16:16

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.

Post Reply