views:

131

answers:

2

I am trying to get a document from Excel or OpenOffice that contains UTF 16 characters into MySQL, but I can't find the best way to export the document so that phpmyadmin will read it. I can export out of NeoOffice as "unicode" format, but the closest option in MySQL is ucs2. When I try that format, it just spins and thinks. UTF8 doesn't support all the characters that I am needing.

+1  A: 

UTF8 does support all the characters of UTF16, it's just that UTF16 crams everything into 2 bytes, while UTF8 can take up to 4 bytes.

MySQL doesn't support UTF16 at this time, because the endianness of the encoding isn't specified, so correctness can't be guaranteed at any time. UTF16 was supposed to be supported for Mysql 6, but since 6 was put on ice, I have no idea what has happened with it.

SQLite supports UTF16 by default though.

Tor Valamo
A: 

Save as UTF-8. If you can't save as UTF-8 directly from your Office software (oh dear!) then load into Notepad-or-similar and save out as UTF-8.

As UTFs, both UTF-8 and UTF-16 can represent the same, complete range of all Unicode characters. UTF-8 is a sensible encoding for files on disc; UTF-16LE (or “Unicode” as Windows very misleadingly describes it) isn't really. UTF-16 can be useful for in-memory storage, but MySQL doesn't use it. Stick with UTF-8 for MySQL storage.

bobince