MySQL and UTF-8

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

MySQL and UTF-8

Jussi Hirvi-2
I think I found an inconsistency in documentation - or I am missing
something. I am using Lasso 8.6.0 on CentOS 5.

Summary: I have to set the encoding for the individual db table, even
though the documentation (the text cited below) mentions an alternative
method: to set Lasso to use the settings of MySQL, and then adjust the
character set directly in MySQL.

The page

http://www.lassosoft.com/Character-Encoding-and-Unicode-Workflow

says:

> If the "Use MySQL 4.1/5.x Character Sets" option is set to Yes in the
> Setup > Data Sources > Hosts section of Lasso Site Administration for
> a MySQL host then Lasso will transmit all data to MySQL in UTF-8 and
> allow MySQL to automatically encode that data according to the table
> definition.
>
> Otherwise, Lasso will use the encoding defined in the Setup > Data
> Sources > Tables section of of Lasso Site Administration for the
> -Table specified in an [Inline]. If no -Table is specified then
> ISO-8859-1 will be used. Note that a "Table Batch Change" option in
> Lasso Site Administration allows all the encoding for all tables on a
> given host or database to be changed at once.

Here is what I did.

First, I set MySQL to use utf8.

mysql> use mydatabase;
mysql> ALTER DATABASE mydatabase DEFAULT CHARACTER SET = utf8;
mysql> ALTER TABLE mytable CONVERT TO CHARACTER SET utf8;
mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | latin1 |
| character_set_connection | latin1 |
| character_set_database   | utf8   |
| character_set_filesystem | binary |
| character_set_results    | latin1 |
| character_set_server     | latin1 |
| character_set_system     | utf8   |
+--------------------------+--------+

mysql> SELECT CCSA.character_set_name FROM information_schema.`TABLES`
T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA WHERE
CCSA.collation_name = T.table_collation AND T.table_name = "mytable";
+--------------------+
| character_set_name |
+--------------------+
| utf8               |
+--------------------+

Now I save an euro character in terminal (utf-8).

mysql> update mytable set myfield='1 €' where id=12;

Verify:

mysql> set character_set_results=utf8;

// I noticed that setting system variables like this is not permanent
// but lasts only for the session

mysql> select myfield from mytable where id=12;
+-----------+
| myfield   |
+-----------+
| 1 €     |
+-----------+

On the browser I see just "1". I have verified that the http header for
my page says "UTF-8".

Now to Lasso Site Admin.

In Setup -> Site -> Lasso Settings I have Default Page Encoding set as
UTF-8 (if it matters).

In Setup - Data Sources -> Hosts I select my MySQL host and set "Use
MySQL 4.1/5.x Character Sets" to Yes.

Still, I see no Euro character in browser - neither my site or Lasso's
Database Browser. According to the text cited above I think i should now
see the Euro character.

I go to Setu -> Data Sources -> Tables, find my table and set the
"Encoding" to UTF-8.

Now I get the Euro character both in my site and Lasso's Database Browser.

Best,
Jussi

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>