Unix Technical Forum

Converting between character sets

This is a discussion on Converting between character sets within the MySQL forums, part of the Database Server Software category; --> If I have a column with the word Dürer in it can I use the Convert function to convert ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:30 AM
starritt@gmail.com
 
Posts: n/a
Default Converting between character sets


If I have a column with the word Dürer in it can I use the Convert
function to convert it to Durer by down-shifting into a 7 bit character
set?! -- I can do this in Oracle. I am scripting with PHP and whenever
I use convert it seems to leave me with a situation where ü becomes a
question mark.

The database is latin1 by default -- if this isnt possible can anybody
think or point me toward a way of querying a column and bring back
records that might have Dürer or Durer only using Durer in my where
clause -- diacritic insensitivity essentially. Working in Oracle
great, but here I am stuck --

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:30 AM
Axel Schwenke
 
Posts: n/a
Default Re: Converting between character sets

starritt@gmail.com wrote:
>
> If I have a column with the word Dürer in it can I use the Convert
> function to convert it to Durer by down-shifting into a 7 bit character
> set?! -- I can do this in Oracle.


When using MySQL you should stay away from Oracle "solutions" ;-)

> The database is latin1 by default -- if this isnt possible can anybody
> think or point me toward a way of querying a column and bring back
> records that might have Dürer or Durer only using Durer in my where
> clause -- diacritic insensitivity essentially.


If your MySQL version is 4.1 or above you can use MySQLs collation
support to achive diacritic insensitive string comparison.
(if your MySQL version is 4.0 or lower you should consider upgrading)

The latin1_german1_* collations work as you expect:

mysql> SELECT 'Dürer' = 'Durer' COLLATE latin1_german1_ci AS german1,
'Dürer' = 'Durer' COLLATE latin1_german2_ci AS german2;
+---------+---------+
| german1 | german2 |
+---------+---------+
| 1 | 0 |
+---------+---------+

The relevant chapter in the manual is:

http://dev.mysql.com/doc/refman/5.0/en/charset.html -- especially
http://dev.mysql.com/doc/refman/5.0/...t-we-sets.html -- and
http://dev.mysql.com/doc/refman/5.0/...t-collate.html


XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:30 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com