2

This query works fine:

set character_set_client = utf8

Same goes for utf8mb4, big5, dec8, cp850, hp8, koi8r, latin1, latin2, swe7, ascii, ujis, sjis, hebrew, etc.

However, when I tried set character_set_client = utf16 or set character_set_client = utf32, they don't work:

#1231 - Variable 'character_set_client' can't be set to the value of 'utf16'

#1231 - Variable 'character_set_client' can't be set to the value of 'utf32'

Why don't the commands work?

How can we make MySQL character_set_client work with utf16/32?

6
  • Mysql version? As mysql says: MySQL 5.5.3. is the minimum to do that Commented Dec 9, 2014 at 8:16
  • @MarcoMura, Mine is 5.5.40-0ubuntu0.12.04.1. MySQL docs only stated ucs2 cannot be used: dev.mysql.com/doc/refman/5.0/en/… . weird eh, I'm suspecting it's a multibyte thing, though the MySQL docs is severely undocumented. Commented Dec 9, 2014 at 8:25
  • It doesn't recognize it. Question: Do you launch that command from mysql client or with php code? Commented Dec 9, 2014 at 8:29
  • @MarcoMura, phpMyAdmin console (v 4.1.0). show character set is showing both utf16 and utf32. Commented Dec 9, 2014 at 8:32
  • Maybe it's a phpMyAdmin Issue. Have you tried putting utf16 between single quotes? Commented Dec 9, 2014 at 8:34

1 Answer 1

1

You can't.

MySQL docs only stated ucs2 cannot be used:

That was the 5.0 doc link. 5.5 says:

ucs2, utf16, and utf32 cannot be used as a client character set

and 5.6 adds utf16le. Essentially MySQL expects queries to be in an ASCII-compatible encoding, each doc version here lists the ASCII-incompatible encodings that version of MySQL knows about.

Is there any particular reason you prefer to use UTF-16? It's generally a bad choice for anything other than talking to other UTF-16 environments (Win32 API, Java etc).

Sign up to request clarification or add additional context in comments.

5 Comments

So basically you mean that all multibyte charsets are "banned"?
Not multibyte exactly—UTF-8, Big-5 and Shift-JIS are all supported multibyte encodings, for example. But the encoding must encode the ASCII characters to the first 128 bytes, which UTF-16/32 don't do because of all the zero bytes.
character_set_client simply sets the charset for statements that arrive from the client, Why must they be ascii-compatible? I don't see any harm in allowing statements in utf16/32.
My guess would be their SQL parser works natively in ASCII and only does charset processing when it hits a literal or schema name.
@bobince can u just let me know answer for my question related to charset stackoverflow.com/questions/28495646/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.