You are here: Re: Smart Trimming of UTF-8 Entities for Database « PHP « IT news, forums, messages
Re: Smart Trimming of UTF-8 Entities for Database

Posted by Eli on 04/08/05 07:15

C Drozdowski wrote:
> I need to be able to store UTF-8 characters from a form into a MySQL
> table. But I need to support pre-UTF-8 MySQL (< 4.1).
>
> So I'm converting UTF-8 characters into their numeric entities (e.g. ñ =
> &#241;).
>
> The problem is that if the user enters a character that gets converted
> to an entity, the string might end up being longer than the field
> definition in the table allows.
>
> For example, if I have a varchar(5) column and try to insert "señor"
> (which has been converted to "sen&#241;or"), I get "sen&#" in the table
> which is useless.
>
> Has anyone dealt with this and if so how?
>
> Thanks in advance for any advice, or pointers to any code that deals
> with this.

You first need to convert to binary charset, and then to the real
charset. Do not convert from current charset to the real charset ahead,
you may cause a data loss.
BEFORE converting - *backup* your databases !!!

http://dev.mysql.com/doc/mysql/en/charset-conversion.html

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация