Send to DB in UTF8
Moderators: gto, EgonHugeist, olehs
Send to DB in UTF8
Hello
How can i send the SQL commands to the database in UTf8? I use Delphi 2010.
The DB and the fields are UTF8. I want to send datas in UTF8 too, so none of characters are lost by the Unicode > latin/cp1250 > Utf8 conversions.
How can i send the SQL commands to the database in UTf8? I use Delphi 2010.
The DB and the fields are UTF8. I want to send datas in UTF8 too, so none of characters are lost by the Unicode > latin/cp1250 > Utf8 conversions.
???? Are you create BD in UTF8 codepage???? Are you sure?
And what DB Server you are use??
My example for PostrgreSQL, for you case it`s parameter may be different.
Check documentation for connect string.
and for write use:
query.ParamByName('Par').AsWideString:='string....';
.......
P.S. Publick you code. i`m want to see it.
And what DB Server you are use??
My example for PostrgreSQL, for you case it`s parameter may be different.
Check documentation for connect string.
and for write use:
query.ParamByName('Par').AsWideString:='string....';
.......
P.S. Publick you code. i`m want to see it.
At the end, this is the solution:
Code: Select all
function convtodb(input: string):string;
var a: PAnsiChar;
w: PWideChar;
Begin
GetMem(w,255);
GetMem(a,255);
StringToWideChar(input,w,255);
UnicodeToUtf8(a,w,255);
Result:=a;
FreeMem(w);
FreeMem(a);
End;
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Why you use this incredible code???!?!!!!!!
Why you can`t use simple example:
(sorry, i`m use C++....)
q : TZQuery;
q.SQL.Clear();
q.SQL.Add('Insert into tbl values (:Z1)');
q.ParamByName('Z1').AsWideString:='in forest born the.... )))';
q.ExecSQL;
db.Commit();
?????
for what do you have to ohm horseradish so perverted? Sorry for my english i`m use Google translate...
why write some stupid function of conversion, if everything is ready in the code itself ZEOS.
Why you use this incredible code???!?!!!!!!
Why you can`t use simple example:
(sorry, i`m use C++....)
q : TZQuery;
q.SQL.Clear();
q.SQL.Add('Insert into tbl values (:Z1)');
q.ParamByName('Z1').AsWideString:='in forest born the.... )))';
q.ExecSQL;
db.Commit();
?????
for what do you have to ohm horseradish so perverted? Sorry for my english i`m use Google translate...
why write some stupid function of conversion, if everything is ready in the code itself ZEOS.