Recent

Author Topic: [solved]zeos character set ?  (Read 13816 times)

Macantutol

  • New member
  • *
  • Posts: 8
[solved]zeos character set ?
« on: February 06, 2012, 01:22:44 pm »
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
« Last Edit: February 07, 2012, 10:19:52 am by Macantutol »
sorry if my english weird, not my regular language :)

M[a]nny

  • Full Member
  • ***
  • Posts: 122
  • Dreamer
Re: zeos character set ?
« Reply #1 on: February 06, 2012, 01:50:32 pm »
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.
Bad news: Time flies.
Good news: You are the pilot.

Don't try to be perfect, just be unique.

Macantutol

  • New member
  • *
  • Posts: 8
Re: zeos character set ?
« Reply #2 on: February 06, 2012, 02:04:57 pm »
no.. my database already utf8, usually i use latin1.. i also already try change my database charset to latin1 but its not working..
sorry if my english weird, not my regular language :)

M[a]nny

  • Full Member
  • ***
  • Posts: 122
  • Dreamer
Re: zeos character set ?
« Reply #3 on: February 06, 2012, 02:13:48 pm »
This command DOES NOT change your table char-coding. It sets up connection char-coding. Just do it.
Bad news: Time flies.
Good news: You are the pilot.

Don't try to be perfect, just be unique.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7430
Re: zeos character set ?
« Reply #4 on: February 06, 2012, 04:45:40 pm »
A better way is to add

codepage=utf8

in your connection properties. (which works afaik for most different DB types)

Zoran

  • Hero Member
  • *****
  • Posts: 1459
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: zeos character set ?
« Reply #5 on: February 06, 2012, 10:21:55 pm »
A 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

  • New member
  • *
  • Posts: 8
Re: zeos character set ?
« Reply #6 on: February 07, 2012, 08:44:09 am »
hello everyone.. thx for your reply..

Quote
codepage=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
sorry if my english weird, not my regular language :)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: zeos character set ?
« Reply #7 on: February 07, 2012, 08:49:59 am »
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...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Macantutol

  • New member
  • *
  • Posts: 8
Re: zeos character set ?
« Reply #8 on: February 07, 2012, 09:09:06 am »
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...
yes.. i forgot

Lazarus 0.9.31 r35168 FPC 2.6.1 i386-win32-win32/win64

Windows XP SP3
sorry if my english weird, not my regular language :)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7430
Re: zeos character set ?
« Reply #9 on: February 07, 2012, 09:33:32 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)
« Last Edit: February 07, 2012, 11:30:43 am by marcov »

Macantutol

  • New member
  • *
  • Posts: 8
Re: zeos character set ?
« Reply #10 on: February 07, 2012, 10:18:48 am »
well.. the problem finally solved.. but.. i replace zeos with TMYSQL51connection, it works fine ..

thx everyone
sorry if my english weird, not my regular language :)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: zeos character set ?
« Reply #11 on: February 07, 2012, 10:33:46 am »
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.