I find a error for oracle in Direct Mode about nvarchar2
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:
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.
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;
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.
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;
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;
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;
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;
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;
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;
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;
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;
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.
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.
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;
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.
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.