I find a error for oracle in Direct Mode about nvarchar2

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Fri 20 Aug 2010 12:29

I reproduced your issue for Server charset = ZHS16GBK and Windows default codepage = 936.

Direct=False & UseUniCode = False - works correct
Direct=False & UseUniCode = True - works correct
Direct=True & UseUniCode = False - works incorrect !!!
Direct=True & UseUniCode = True - works correct

Please confirm the result of my tests.

I am going to fix the bug for the mode: Direct=True & UseUniCode = False. If you have invalid result for other modes, please notify me.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Fri 20 Aug 2010 14:05

i am glad to get your result:

Direct=False & UseUniCode = False - works correct
Direct=False & UseUniCode = True - works correct
Direct=True & UseUniCode = False - works incorrect !!!
Direct=True & UseUniCode = True - works correct

my test in winXP is same with you .

but In win7,Direct=False & UseUniCode = False has wrong .

for example ,if you field is varchar2(5), then
you can write '戴大达' in DbEdit,but when you post ;
'戴大达' =>'戴大?';
if at winXP or Win2003 ,the result is '戴大达' =>'戴大' ,this is OK.

if you are not mind of you new code ; can you give the code you fixed to me ; my e-mail :[email protected] , i'll try my best to help you test

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Fri 20 Aug 2010 14:16

i hope you test like this:

uniQuery+dataSource+DbGrid,

create a table include varchar2,nvarchar2,varchar2( char)

write chinese char in DbGrid as long as you can input ,then post;
and you can input chinese mix english too.

if you see '?' , it shows error.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Sat 21 Aug 2010 09:25

Thank you for the information. We have fixed the bug with Direct=True & UseUniCode = False . Now we will run the same tests under Win7 and we will fix all errors that will be found. After this we will send you fixed files for testing.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Sat 21 Aug 2010 11:19

I run all my 4 tests under Windows 7 + Delphi 2010 + Oracle 11g client. I got the same result as under Windows XP. Please repeat your tests under Windows 7.

Also please provide the Oracle client version that you are using under Windows 7.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Sat 21 Aug 2010 14:51

I made my test ,Please See this video:

http://www.daizhicun.com/unidac/uniDac.html

and i hope you give the fixed code to me :[email protected]

i will test it carefully.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Sat 21 Aug 2010 14:54

i use oracle server/client all at oracle11gR2 .
and i test it errors at oracle11gR1 too.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Sat 21 Aug 2010 15:00

In this:
http://www.daizhicun.com/unidac/uniDac.html

it shows many bugs;

but in fact ,the bugs about chinese is more then it showed ;

so ,we must test and test ;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Sun 22 Aug 2010 01:20

or you can download my test:
http://www.daizhicun.com/unidac/uniDac.mp4

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Mon 23 Aug 2010 00:12

Mr.bork
did you test errors like i test?

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Tue 24 Aug 2010 23:58

waiting the answer

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 25 Aug 2010 10:18

Hello

I reproduced the issue from the video. It seems like Delphi bug or Oracle bug. Let consider the sample:

We want to save the "漢語3金金金" value to NVARCHAR(5) field. In any case TStringField call the TStringField.SetAsAnsiString method in the DB unit and convert your WideStrng to AnsiString: "漢語3金金金" = $9D $68 $D5 $5A $33 $BD $F0 $BD $F0 $BD $F0 (11 bytes in UTF8 for AnsiString).

The TStringField.SetAsAnsiString cut this string to 10 byte (field has size 10):

Code: Select all

procedure TStringField.SetAsAnsiString(const Value: AnsiString);
var
  Len: Integer;
  PBuf: PAnsiChar;
  Temp: AnsiString;
  Buffer: array[0..dsMaxStringSize] of AnsiChar;
begin
  if DataSize > SizeOf(Buffer) then
  begin
    SetLength(Temp, strlen(PAnsiChar(Value))+1);
    PBuf := PAnsiChar(Temp);
    Len := StrLen(PAnsiChar(Value));
  end else
  begin
    PBuf := Buffer;
    Len := Size;
  end;
  StrLCopy(PBuf, PAnsiChar(Value), Len);  SizeOf(Buffer) then
  begin
    SetLength(Temp, strlen(PAnsiChar(Value))+1);
    PBuf := PAnsiChar(Temp);
    Len := StrLen(PAnsiChar(Value));
  end else
  begin
    PBuf := Buffer;
    Len := Size;
  end;

  // cut string
  Temp := copy(Value, 1, Len);
  // $9D $68 $D5 $5A $33 $BD $F0 $BD $F0 $BD -> $9D $68 $D5 $5A $33 $BD $F0 $BD $F0 (remove remains of characters)
  Temp := WideString(Temp);
  // copy the value to the buffer
  StrLCopy(PBuf, PAnsiChar(Temp), Len);

//  StrLCopy(PBuf, PAnsiChar(Value), Len);
  if Transliterate then
    DataSet.Translate(PBuf, PBuf, True);
  SetData(PBuf);
end;
4. Write request to Embarcadero and ask them to develop fix for the TStringField.SetAsAnsiString method.

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 25 Aug 2010 11:10

greatly!

--
i will update TStringField.SetAsAnsiString method as you wirite;
and test again.

4. Write request to Embarcadero and ask them to develop fix for the TStringField.SetAsAnsiString method.

-- i hope you tell Embarcadero to fix it ,because your firm is a famous firm;

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 25 Aug 2010 11:44

i have fix db.pas as you .
and i put fixed db.pas to my project directory.

But then proect can't run:

[DCC Fatal Error] DBAccess.pas(2335): F2051 Unit DBCommon was compiled with a different version of DB.TDataSet

daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Wed 25 Aug 2010 11:54

It seems like Delphi bug or Oracle bug.
-- but when i Use Toad or Pl/sql developer ,they are OK for chinese.
they are all made from delphi and use the same oracle ;

Post Reply