views:

24

answers:

1

I want to insert a record into MySQL that has a non-ASCII Unicode character, but I'm on a terminal that doesn't let me easily type non-ASCII characters. How do I escape a Unicode literal in MySQL's SQL syntax?

+1  A: 

See: http://bugs.mysql.com/bug.php?id=10199 (Bug #10199: "Allow Unicode escape sequence for string literals.") This request has been "Open" since 2005.

From http://eng.kaching.com/2009/10/mysql-unicode-escape-sequences.html though you can see the following example, which does actually seem to work, but requires you to know the actual byte-by-byte UTF8 encoding:

"You can also use the variable-length UTF-8 representation (convenient when, for example, copying from a utf-8 URL-encoded value like %E2%80%98)."

mysql> select _utf8 x'E28098';
+---+
| ‘ |
+---+
dkamins