View Single Post

  #2 (permalink)  
Old 04-18-2007
Willem Bogaerts
 
Posts: n/a
Default Re: insert/update special characters

> I've been fighting with this for awhile, but can't seem to figure out how to
> successfully insert/update special characters.
>
> Take the 'registered' symbol for example:
>
> "My Brand®"
>
> After inserting like so the record contains an extra character
>
> "My Brand®"
>
> I can get the former string to output properly with utf8_encode(), but ends
> up looking like the latter after an insert/update.


What you see is the unicode representation of a latin-1 text. A lot
depends on which MySQL version you are using. If you are Using 5.x, send
a SET NAMES <encoding> command directly after connecting. Otherwise,
MySQL will default to using latin-1 and (re-)transscribe to the field
encoding, whatever you configure.

And off course, define the right encodings for your fields. Although the
latter is more for your own documentation: utf-8 will fit perfectly in a
latin-1 field, for example.
The ultimate test is the mysqldump utility. If you dump a table with
special characters, mysqldump will show you how they are stored internally.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Reply With Quote