[Gambas-user] gb.db (Charset)

Benoit Minisini gambas at ...1...
Fri Oct 26 13:31:37 CEST 2007


On vendredi 26 octobre 2007, Benoit Minisini wrote:
> On mercredi 24 octobre 2007, Benoit Minisini wrote:
> > On mercredi 24 octobre 2007, David Villalobos Cambronero wrote:
> > > Hi all,
> > >
> > >     One of these days I realised somethig interesting. I use MySQL
> > > version 6.0, and I create my databases manually, I mean, I don't use
> > > gambas-database-manager for that. All my databases uses UTF-8, but when
> > > I see the values in the connection, the property Charset has the value
> > > "latin1", this property has to be UTF-8, right?
> > >
> > >     I haven't  any problem with this, but to me, it seems a bug. By the
> > > way I use Mandriva 2007.1 and Gambas 1.9.90.
> > >
> > > Regards
> > >
> > > David
> >
> > Right, I noticed the same problem with MySQL 5 on Mandriva 2008.
> >
> > I think that the database client tells by default to the server that it
> > want "latin1", even if the server uses UTF-8!
> >
> > But I must investigate to understand what happens really.
> >
> > Regards,
>
> Well, on Mandriva 2008 it seems that the mySQL server cannot be switched
> to "UTF-8", and that the client cannot change its character set to "UTF-8"
> (with the mySQL SQL command 'SET NAMES'). "UTF-8" is a unknown character
> set... So t seems logical that the client charset is "latin1".
>
> According to the documentation, when the client connect, it gets by default
> the default charset of the server, which should be UTF-8 in your case. So I
> don't see how you can get "latin1". What happens if you connect to your
> UTF-8 server with the mysql command? Do you have latin1 as default
> character set? What is the default charset of the OS ($LANG variable)?

Oops. I was wrong. It is just a matter of using "UTF8" and not "UTF-8". So 
weird...

But apparently "latin1" is the default character set, even if my system is set 
to UTF-8.

As for what value should have DB.Charset, it depends on your point of view:

* You can keep the default. Note that DB.Charset is not the charset of the 
database, but the charset of the connection. Keeping the default is easier, 
as then the code does not depend on the database backend: it does nothing :-)

* You can use the server database charset.

* You can use the charset of the client OS.

I find the last the more logical. After all, if the current charset of OS 
is "XYZ", you would like the database server to talk to you with the same 
charset.

Note that changing the charset is not possible in all database backends, and 
is not supported by the database component at the moment. And that you can 
issue a MySQL SQL command if you really need a specific charset.

Tell me what you think about that...

Regards,

-- 
Benoit Minisini




More information about the User mailing list