Hi,
I have a problem with TUniSQL component.
I want to insert a string that is encrypted... in a MySQL table but the string is changed.
Text that I want to insert
—•yu¯ÐßÊE<[©su¦¯˜¶•h¡†¥™²˜¢¶¨zv\¶xi¨ž–ª©h~J—”ž˜—§–hb3{b@o›ÏØÈ›×©ÒÌà˜uk
Text in MySQL DB
—•yuŻĐßĘE<[©su¦Ż¶•hˇ†Ą™˛˘¶¨zv\¶xi¨ž–Ş©h~J—”žť—§–hb3{b@o›ĎŘțשŇĚŕuk
Some characters are changed ....yu¯ to yuŻ
If I write this string in DB manualy it works ...
I try also with Parameters but is the same result. I changed the connection to UniCode,I try with charset UTF8 but I didn't find a solution.
What I did wrong?
Unidac version is 4.1.3
Delphi 2006
Thanks !
Unidac Special Characters
-
softwestteam
- Posts: 10
- Joined: Fri 29 May 2009 10:43
- Location: Romania, Arad
Re: Unidac Special Characters
Hi,
in MySQL I prefer to use BLOB type for raw strings.
And I prefer to use these functions (maybe is not the best way but it works):
You can use TBytes and read with .AsByte. This is pretty similar with AnsiString I used.
If you use WideString you need to modify the functions accordingly.
If you need more help, please specify your MySQL field type and how do you read and write values.
Best Regards,
Cristian Peţa
in MySQL I prefer to use BLOB type for raw strings.
And I prefer to use these functions (maybe is not the best way but it works):
Code: Select all
procedure WriteAnsiStringToBlob(AField: TField; s: AnsiString);
var
strm: TStream;
begin
strm := AField.DataSet.CreateBlobStream(AField, bmWrite);
try
if Length(s) > 0 then
strm.Write(s[1], Length(s)) else
strm.Size := 0;
finally
strm.Free;
end;
end;
function ReadAnsiStringFromBlob(AField: TField): AnsiString;
var
strm: TStream;
begin
strm := AField.DataSet.CreateBlobStream(AField, bmRead);
try
SetLength(Result, TBlobField(AField).BlobSize);
if TBlobField(AField).BlobSize > 0 then
strm.Read(Result[1], TBlobField(AField).BlobSize);
finally
strm.Free;
end;
end;If you use WideString you need to modify the functions accordingly.
If you need more help, please specify your MySQL field type and how do you read and write values.
Best Regards,
Cristian Peţa
Last edited by CristianP on Tue 19 Feb 2013 14:17, edited 1 time in total.
-
DemetrionQ
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Unidac Special Characters
Hello.
The matter is that different applications can work with the DB in different encodings, therefore the same data is displayed in different ways. Please check that the data is really different and this is not the problem with data displaying, for example, by opening the table using the TMyQuery and TMyTable components.
In addition, please specify what do you use to view the table and what do you mean by "write this string in DB manualy".
The matter is that different applications can work with the DB in different encodings, therefore the same data is displayed in different ways. Please check that the data is really different and this is not the problem with data displaying, for example, by opening the table using the TMyQuery and TMyTable components.
In addition, please specify what do you use to view the table and what do you mean by "write this string in DB manualy".