Unicode - DB2

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Unicode - DB2

Post by Daril » Tue 25 Oct 2011 12:27

Hi,
I try query during TUniQuery this

SELECT V.VIEWSCHEMA,V.VIEWNAME FROM SYSCAT.VIEWS AS V WHERE V.VIEWNAME='VЖ҉ﻺ۩ﭷѠϢѪϟV'

I have in my DB view with name 'VЖ҉ﻺ۩ﭷѠϢѪϟV', but this query return empty result. When I try only

SELECT V.VIEWSCHEMA,V.VIEWNAME FROM SYSCAT.VIEWS

view is present in result.

I have UseUnicode switch to true.

I don't know what it is wrong.

Thank you for response
I Use Delphi 7. Is it problem? I have problem with TMemoField and unicode too. Is it because I use D7? Any work around?


Daril

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 26 Oct 2011 14:29

hello,

Delphi 7 does not support working with Unicode. Unicode symbols are supported starting with Delphi 2009.

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Post by Daril » Mon 12 Mar 2012 09:31

Hello,
I discover that with older version of unidac(Unidac version 1.00.0.7 for Delphi 7) I can use unicode character when query.sql code to UTF8.
But when I use new version (Unidac version 4.0.1 for Delphi 7), this not work.
I need this functionality return to our product, because it was implemented with older unidac. Now I tested it on Oracle, but i think it will be same problem as DB2.

Any Ideas why?

I tryed debug program and use query.SaveToXml to compare with older version. I see that in new is empty element: (maybe will be usefull).

Thank you
Petr

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 12 Mar 2012 15:01

Hello,

Please specify your Windows regional settings, font, and encoding used in Delphi 7

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Post by Daril » Mon 12 Mar 2012 15:37

Hi,
Windows: Windows 7 64b
regional settings: United states
I'm not sure which font. I use tntMemo for insert sql statement in both exmaple(old, nee component), font is MS Sans Serif.
I try write UTF-8 string and it is same.

This is code of test program:

Code: Select all

function ConvertWideStringToUtf8(Value: WideString): UTF8String;
var
  Temp  : UTF8String;
  Copied: Integer;
begin
   Result := '';
   SetLength( Temp, Length( Value ) * 3 );
   Copied := UnicodeToUtf8(PChar(Temp), Length(Temp)+1, PWideChar( Value ), Length( Value ));
   if Copied > 0 then
   begin
     SetLength( Temp, Copied-1 );
     Result := Temp;
   end;
end;

procedure TForm1.TntButton1Click(Sender: TObject);
begin
UniConnection1.Connect;
UniQuery1.SQL.Text := ConvertWideStringToUtf8(TntMemo1.Lines.Text);
Uniquery1.Execute;

end;
It is work with Unidac 1.0.0.7



Petr

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Post by Daril » Mon 12 Mar 2012 15:38

This is my test query:

select OWNER, NAME, LINE, TEXT from SYS.ALL_SOURCE where OWNER='SCOTT' and NAME='豪猪' and TYPE='PROCEDURE' order by LINE

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 14 Mar 2012 11:10

Hello,

You are using non-standard third-party components for work with UniDAC symbols. Maybe the problem is due exactly to them, try to reproduce the problem using the standard components.

P.S. When working with Delphi versions that support UniCode (since Delphi 2009), your queries run correctly and return correct datasets

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Post by Daril » Thu 15 Mar 2012 12:53

Hello,
I use email to reply, because I don’t see how can I post attachments.

In Attachments are two projects. One is with unidac version 1.0 and second with unidac version 4.0(Both are for Delphi 7). You can see code is identical and I use only VCL standard components. With unidac version 1.0 works perfects and I get some results. With unidac version 4.0 I don’t get any results.

Petr

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 19 Mar 2012 10:05

Hello,

We have fixed work with the UniCode symbols, and this fix will be available in the next UniDAC version. However, a more correct solution is using parametrized queries, as, in this case, you are not dependent hard from the charset, and you can choose a charset for the concrete symbols specifying it in the UniConnection.SpecificOptions.Value['Charset'] property (for your example, it would be enough to set the charset value as UniConnection.SpecificOptions.Value['Charset'] := 'AL32UTF8';)

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Unicode

Post by Daril » Mon 19 Mar 2012 11:57

Hello Alex,

it is good news for me. :-)
Could yous specify when will be next version with this fix?

I try to use your workaround with charset AL32UTF8. It is works, when set UseUnicode to false. Unfortunatelly result is in utf8 to, but it is only minor problem.

Beause I hurry to solve this problem I tryed during weekend deploy dll in Delphi XE2 with Unidac 4.1. But I see, there is some similar problem with unicode. I don't code query to UTF8 and set UseUnicode to true, but I don't get result, when I use unicode char in where clause. I verified it in simple project in XE2.

XE2 simple project:
Query: Select * from TestUnicodeDaril Where Name='Ѫϟ'
Connection Options: UseUnicode := True;
Direct := True;
Charset := '';

Code: Select all

  ...
  UniConnection1.Server := EdServer.Text;
  UniConnection1.Connect;
  if UniConnection1.Connected then
  begin
    UniQuery1.SQL.Text := Select * from TestUnicodeDaril Where Name=''Ѫϟ'';
    UniQuery1.Execute;
  end;
  ...

Could you confirm please that is same problem as in Delphi7? If yes I know, that work around by dll is not solution for me.

Thank you
Petr

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 19 Mar 2012 16:08

Hello,

For work with such strings in Delphi XE2, besides turning on the UseUnicode option, you should also set the OCIUnicode global variable to true, this variable is declared in the OraCallUni module.

Daril
Posts: 27
Joined: Fri 07 Oct 2011 09:58

Post by Daril » Tue 20 Mar 2012 14:32

Hello,
thank you for quick reply. UseUnicode flag doesn't work in XE2, but OCIUnicode global variable work perfect.
I tested another db platform(MySQL, MSSQL, PG, DB2) too. There useunicode flag works good.

Thank you for cooperation
Petr

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Thu 22 Mar 2012 14:10

Hello,

Such behaviour (the necessity of using the OCIUnicode variable) depends on the Oracle specificity. When enabling UseUniCode only, it is allowed to use UniCode symbols transferred by means of parameters; when enabling OCIUniCode, such symbols are allowed directly in the query body

Post Reply