|
-
March 15th, 2007, 09:16 PM
#1
Saving UTF8_bin strings properly on MySQL
Hi,
I'm using MySQL and phpMyAdmin with tables and collation using the UTF8_bin encoding. I'm storing strings from a webpage form with PHP, with the UTF8 charset content-type specification.
Strings are always displayed correctly on the webpage, but are not saved right on the database. For example, the spanish word árbol becomes árbol in the database. Yet it's always displayed right on the webpages, but on the database it takes an extra character thus reducing the actual string capacity.
The question is, how do I save these strings with accents (I'm not needing to save greek or arabic, yet that would be good) properly on the tables, and if PHP should make the conversion, how to do it.
Thanks in advance.
-
March 22nd, 2007, 07:57 AM
#2
Re: Saving UTF8_bin strings properly on MySQL
I'm not familiar with MySql however I do have similar problem with Oracle.
The problem (in my case) is that when it was installed on the server it wasn't configured to as UTF based so there is no way to save correct unicode chars unless system is rebuilt wich isn't going to happen.
Since I only care about few special chars like [® © ™] my solution was to replace those before data is saved with actual char number presented as text:
® --> "chr(174)"
when you read back from DB you will simply convert it back
"chr(174)" --> ®
But as I said I only had few to worry about...
There are no miracles in programming...
RB
Microsoft Visual Basic MVP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|