1

サンプルコードは次のとおりです。

CREATE DATABASE test_unicode DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

USE test_unicode;

CREATE TABLE simple_table (text varchar(100) NOT NULL);

INSERT INTO simple_table VALUES ('l\u2019agave');

SELECT * FROM simple_table;

そして、ここに出力があります:

+-------------+
| text        |
+-------------+
| lu2019agave |
+-------------+
1 row in set (0.00 sec)

Mysql は " \ "なしで文字列を保存しました

- " \ "で "l\u2019agave" を取得する必要があります

どうすればそれができますか?

私はmysqlに多くのエンコーディング設定を試みましたが、うまくいきません...

アドバイスありがとうございます!

4

3 に答える 3

1

これを試して :

INSERT INTO `test_unicode`.`simple_table` (`text`) VALUES ('l\\u2019agave'); 

This is because MySQL uses C escape syntax in strings (for example, “\n” to represent a newline character), you must double any “\” that you use in LIKE strings. For example, to search for “\n”, specify it as “\n”. To search for “\”, specify it as “\\”; this is because the backslashes are stripped once by the parser and again when the pattern match is made, leaving a single backslash to be matched against.

于 2013-07-08T11:47:51.720 に答える