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)
daizhicun
Posts: 109
Joined: Thu 21 Jan 2010 11:49

Post by daizhicun » Thu 26 Aug 2010 03:20

Perhpas there are not good ways to solve this problem

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

Post by daizhicun » Fri 27 Aug 2010 03:59

i find that thsi error (chinese show '?') is come from win7;

becacuse , i find it is ok at winXP,win2003,Vista;

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

Post by daizhicun » Sun 29 Aug 2010 07:03

i hope that the new version of UniDac which will pubilsh can solve some bugs of show chinese char at win7.

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

Post by bork » Mon 30 Aug 2010 13:56

Hello

I get the same error in Windows XP and in Windows 7: in the memory 漢語3金金金 is stored as $9D $68 $D5 $5A $33 $BD $F0 $BD $F0 $BD for any OS. Probably Windows XP with your regional settings skips the cut character $BD, but Windows 7 shows it as "?". But in any case this error is present in both OSs.

If you don't purchase UniDAC with source code, then you cannot change the DB unit, because you will get the following error:
[DCC Fatal Error] DBAccess.pas(2335): F2051 Unit DBCommon was compiled with a different version of DB.TDataSet

But there is another way. You can declare your own class:

Code: Select all

TMyUniQuery = class (TUniQuery)
private
protected
public
  function Translate(Src, Dest: PAnsiChar; ToOem: Boolean): Integer; override;
end;

function TMyUniQuery.Translate(Src, Dest: PAnsiChar; ToOem: Boolean): Integer;
var
  Temp: AnsiString;
begin
  Temp := AnsiString(Src);
  Temp := WideString(Temp);
  inherited Translate(PAnsiChar(Temp), Dest, ToOem);
end;
This code does the same as changing the DB unit does, because TStringField calls the TDataSet.Translate method on each TStringField modification.

We will consider adding this code for all our users (converting PAnsiChar->AnsiString->WideString->AnsiString->PAnsiChar can impair performance), but for now you can use this solution.

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

Post by daizhicun » Tue 31 Aug 2010 11:07

thanks ,i make a common mothed:
In file:MemDS.pas

I add this function:

function Translate(Src, Dest: PAnsiChar; ToOem: Boolean): Integer; override;


function TMemDataSet.Translate(Src, Dest: PAnsiChar; ToOem: Boolean): Integer;
var
Temp: AnsiString;
begin
Temp := AnsiString(Src);
Temp := WideString(Temp);
inherited Translate(PAnsiChar(Temp), Dest, ToOem);
end;


but , i find the same error about '?' in chinese char;

i am waiting for then new version to solve this ploblem;

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

Post by daizhicun » Tue 31 Aug 2010 11:21

i find this code had been hide:

function TMemDataSet.Translate(const Src: string; var Dest: string; boolean): integer;
begin
inherited Translate(Src, Dest, ToOem);
Result := StrLen(Src);
if ToOem then
AnsiToNativeBuf(Locale, Src, Dest, Result)
else
NativeToAnsiBuf(Locale, Src, Dest, Result);
if Src Dest then
Dest[Result] := #0;
end;

i don't know why this code be hided?

perhpas it can solve this ploblem;

but this function's params type difient of its father function;

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

Post by daizhicun » Tue 31 Aug 2010 11:55

Image

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

Post by daizhicun » Tue 31 Aug 2010 12:05

in above pic,
if at win2003 server ,it is OK at delphi2010 ;


My Key Code for Hex->ascii

//hex -> ascii
function TCommon.Encode1(buf: array of Byte; iHead: Integer; iend: Integer):
string;
var
I: Integer;
Str: AnsiString;
begin

for I := iHead to iend do

Str := Str + AnsiChar(buf);
//i add " Str:=WideString(Str);"
// but 9D 68 D5 5A 33 BD F0 BD F0 3F -> 漢語3金金? at win7 too.
// and it is ok at windows 2003server
Str:=WideString(Str); // it is not useful;
Result := Str;
end;

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

Post by daizhicun » Tue 31 Aug 2010 13:01

9D 68 D5 5A 33 BD F0 BD F0 BD
at winXP or win2003 server:漢語3金金
at windows 7 :漢語3金金?

demo code:
procedure TForm1.Button1Click(Sender: TObject);
var
Str: ansiString;

begin
str:=ansiChar($9D) +ansiChar($68) +ansiChar($D5) +ansiChar($5A)+
ansiChar($33) +ansiChar($BD) +ansiChar($F0) +ansiChar($BD)+
ansiChar($F0 )+ ansiChar($BD);
edit1.text:=str;
end;

i have asked it at famous delphi bbs in china:

http://www.delphibbs.com/delphibbs/disp ... id=3999327

http://bbs.2ccc.com/topic.asp?topicid=360224
http://atkins.5d6d.com/thread-18224-1-1.html


this is a bug at Delphi2010 in Win7 ;

i hope you ask Delphi Firm to solve this plobem;

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

Post by daizhicun » Tue 31 Aug 2010 13:08

i use you method, it is not useful:

procedure TForm1.Button1Click(Sender: TObject);
var
Str: ansiString;
Temp: AnsiString;
begin
str:=ansiChar($9D) +ansiChar($68) +ansiChar($D5) +ansiChar($5A)+
ansiChar($33) +ansiChar($BD) +ansiChar($F0) +ansiChar($BD)+
ansiChar($F0 )+ ansiChar($BD);
Temp := AnsiString(str);
Temp := WideString(Temp);
edit1.text:=Temp;
end;

it is show '?' too.

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

Post by daizhicun » Sat 04 Sep 2010 05:03

juse now ,i tested it at ADO in Delphi2010;
it has the same error '?' in Win7 when show half chinese char;

so this bugs must come from DB.pas;
we can solve it by modify DB.pas (but now i don't know how to modify,
it is not useful: str:=WideString(str) )




but we must solve this problem:

Image

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

Post by daizhicun » Mon 27 Sep 2010 10:40

i find a way to solve '?' in chinese .

Code: Select all

procedure TcvFrm.Button1Click(Sender: TObject);

var
  Chs: TBytes;
  iL, I: Integer;
  S: AnsiString;
begin
  SetLength(Chs, 10);
  Chs[0] := $9D;
  Chs[1] := $68;
  Chs[2] := $D5;
  Chs[3] := $5A;
  Chs[4] := $33;
  Chs[5] := $BD;
  Chs[6] := $F0;
  Chs[7] := $BD;
  Chs[8] := $F0;
  Chs[9] := $BD;

  S := '';
  iL := Length(Chs);
  if iL > 0 then
  begin
  if ByteType(AnsiChar(Chs[iL - 1]), 1) = mbLeadByte then
      SetLength(Chs, iL - 1);

    for I := Low(Chs) to High(Chs) do
      S := S + AnsiChar(Chs[I]);
  end;

  Caption := S;
end;

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

Post by bork » Fri 08 Oct 2010 12:35

Hello

It is good to see that this problem was solved. But we cannot use this fix in our product because besides the Chinese charset other charsets with 3 and 4 bytes per 1 char exist, and this fix will not be applicable for them. We will look for a universal solution for all charsets.

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

Post by daizhicun » Sun 17 Oct 2010 11:12

I find the new version Uniac has new bug for chinese show.

Image

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

Post by bork » Wed 20 Oct 2010 10:05

Hello

Please post you issues about the same problem in one topic. If you post you issues in this topic and here:http://www.devart.com/forums/viewtopic.php?t=19261 then I can miss some information and give you invalid answer.

Post Reply