[solved]zeos character set ? lazarus / 16-Databases ---------------------------------------------------------------------- Macantutol · 2012-02-06 12:22 hello, i want to ask about zeos charset & collation.. zeos ver. : 7.0.0-dev mysql ver : 5.0.8 my database charset : utf8 -- UTF-8 Unicode my database collation : utf8_general_ci i just connecting to my mysql db and i got my varchar field showing weird characters in my dbgrid (please take a look my attachment).. i also try to change my grid font charset to unicode but nothing happened i thought it has something to do with zeos charset setting, is there a way to change zeos charset and collation? sorry if my english weird .. not my regular language  warm regards ---------------------------------------------------------------------- M[a]nny · 2012-02-06 12:50 All you have to do is make a query after sucessfull connection: Code: [Select]procedure TForm1.Connection1AfterConnect(Sender: TObject);  var   Q: TZQuery; begin   Q := TZQuery.Create(nil);   Q.Connection := Form1.Connection1;   Q.SQL.Text := 'SET CHARACTER SET utf8';   Q.ExecSQL;   Q.Free; end; Since this moment, all queries will return strings in UTF-8. ---------------------------------------------------------------------- Macantutol · 2012-02-06 13:04 no.. my database already utf8, usually i use latin1.. i also already try change my database charset to latin1 but its not working.. ---------------------------------------------------------------------- M[a]nny · 2012-02-06 13:13 This command DOES NOT change your table char-coding. It sets up connection char-coding. Just do it. ---------------------------------------------------------------------- marcov · 2012-02-06 15:45 A better way is to add codepage=utf8 in your connection properties. (which works afaik for most different DB types) ---------------------------------------------------------------------- Zoran · 2012-02-06 21:21 Quote from: marcov on February 06, 2012, 04:45:40 pmA better way is to add codepage=utf8 in your connection properties. (which works afaik for most different DB types) Yes, although both suggested ways will work, this is better way because the data will show correctly in design time too. If you set charset in AfterConnect event handler, as Manny suggested, it will work well in runtime, but it will not affect design-time connection, so the data may look wrong in design-time. ---------------------------------------------------------------------- Macantutol · 2012-02-07 07:44 hello everyone.. thx for your reply.. Quotecodepage=utf8 thankyou for the suggestion, but unfortunately, this also not working yesterday i tried to connect with delphi 7 + zeos(same version) and its works really fine without any problem just like usual.. see.. thats really confusing  i upload(see attachment) the same model of my problematic database.. if you have freetime, please try it with your zeos + lazarus thanks ---------------------------------------------------------------------- BigChimp · 2012-02-07 07:49 While having the DDL of your database is nice, it would really help to share a Lazarus project that shows the problems... Finaly, it always helps to tell us your operating system+lazarus+fpc version... ---------------------------------------------------------------------- Macantutol · 2012-02-07 08:09 Quote from: BigChimp on February 07, 2012, 08:49:59 amWhile having the DDL of your database is nice, it would really help to share a Lazarus project that shows the problems... Finaly, it always helps to tell us your operating system+lazarus+fpc version... yes.. i forgot Lazarus 0.9.31 r35168 FPC 2.6.1 i386-win32-win32/win64 Windows XP SP3 ---------------------------------------------------------------------- marcov · 2012-02-07 08:33 Quote from: Macantutol on February 07, 2012, 08:44:09 am yesterday i tried to connect with delphi 7 + zeos(same version) and its works really fine without any problem just like usual.. see.. thats really confusing  I'm not sure, but IIRC you have to reimport queries after that change. widememos instead of memos will then be created. (though that is also required on Delphi) The same for fields (widestringfield vs stringfield or so) ---------------------------------------------------------------------- Macantutol · 2012-02-07 09:18 well.. the problem finally solved.. but.. i replace zeos with TMYSQL51connection, it works fine .. thx everyone ---------------------------------------------------------------------- ludob · 2012-02-07 09:33 Looking at the screen shots, I'm afraid this is not related to character sets. The db columns contains all ascii characters and in utf8 or latin they have the same code. The other hint is that all values are the same in the 2 columns while the contents in the db is different. If this where a char set issue you would have a lot of weird characters but varying according to the field value. Posting a minimal program to shows the problem would be useful.