1
問題:在播放字符編碼! 1.2.4框架變成。文字編碼轉換播放中的垃圾字符! 1.2.4框架
語境:我們正在試圖存儲從輸入文本字段 「」我叫MT繁體版「臺港澳專屬伺服器上線」 用玩到mysql! 1.2.4框架。
步驟,我們遵循:
1)用戶界面得到用戶的輸入。只是任何朗文本,所以我們嘗試了Japneese Char。注意:頁面設置爲UTF-8字符編碼。
2)後提交玩!控制器,控制器只讀取輸入並使用Play進行存儲!模型。片斷下面mentiond,
public static void text_create() throws UnsupportedEncodingException,
ParseException {
System.out.println("params :: text string value :: " + params.get("text"));
String oldString = params.get("text");
// Converting the input string(which is UTF-8 format) and parsing to Windown-1252
String newString = new String(oldString.getBytes(), "WINDOWS-1252");
// 1. passing encoded text to mysql.
// 2. TextCheck table and the column 'text' has encoding and collation format as UTF-8.
// 3. TextCheck > text column mentioned as String in model.
TextCheck a = new TextCheck(newString);
List<Object> text = TextCheck.TextList();
render(a,text);
}
問題是有價值之間的字符 。當我使用其他平臺如Java,Ruby或將其轉換反而使得那些字符作爲垃圾某些 其他語言讀從MySQL這個 原始數據。只是 垃圾。
注意: Interstingly當我從相同的播放!框架。即使垃圾字符被正確讀取,它看起來一切正常。
問:爲什麼那些垃圾字符?