Pacerier
Pacerier

Reputation: 89623

How to make MySQL character_set_connection work with utf16?

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?

Upvotes: 2

Views: 1542

Answers (1)

bobince
bobince

Reputation: 536379

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).

Upvotes: 1

Related Questions