我正在尝试开发一个韩语词汇应用程序,但我无法将韩语单词插入数据库并显示它们:它们显示为一串奇怪的字符。有没有办法解决这个问题?或者我只能将韩语单词显示为图像?我需要配置一些东西吗?
到目前为止,我将文本文件编码更改为“Other:UTF-8”。但这并不能解决问题。我现在正在使用 Android Phonegap 进行开发。任何提示或提示将不胜感激。谢谢你。
===更新====
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Populate the database
//
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, kword TEXT NOT NULL, eword TEXT NOT NULL, pronoun TEXT NOT NULL, level INTEGER NOT NULL)');
tx.executeSql('INSERT INTO DEMO (id, kword, eword, pronoun, level) VALUES ("1", "점심", "Lunch", "jeomsim", "1")');
tx.executeSql('INSERT INTO DEMO (id, kword, eword, pronoun, level) VALUES ("2", "晚餐", "Dinner", "naeil", "1")');
}
// Query the database
//
function queryDB(tx) {
tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}
// Query the success callback
//
function querySuccess(tx, results) {
var data ='';
var len = results.rows.length;
localStorage.tablerows = len;
for (var i=0; i<len; i++){
data = data +"<tr><td>"+results.rows.item(i).id +"</td><td>"+ results.rows.item(i).kword+ "</td><td>" + results.rows.item(i).eword +"</td></tr>" ;
}
display(data);
}
// Transaction error callback
//
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
// Transaction success callback
//
function successCB() {
var db = window.openDatabase("Database", "1.0", "Vocabulary", 200000);
db.transaction(queryDB, errorCB);
}
// PhoneGap is ready
//
function onDeviceReady() {
var db = window.openDatabase("Database", "1.0", "Vocabulary", 200000);
db.transaction(populateDB, errorCB, successCB);
}
function display(data){
$('table#vocab').css('display','block');
$('table#vocab tbody').append(data);
}
</script>