質問

I have a web page, and that web page has a JavaScript saved in another file, that is loaded into the web page. When webpage is loaded, JavaScript will create a table, and then it will output something into the cells of the table.

However, when I want to output Chinese Character like: "你好"。 Things screwed up, like this: ��������

How do I solve this problem so I can output the Chinese character?

Figure out where the problem come from: I load strings from text file, and those strings will be output to table. And those strings, if are Chinese, are turned into question marks.

Trying Unicode:

Code where I get problematic strings:

function get_Audio_List()
{   
$.get(list_File, function(data, status){

    // Debug Output..
    ( (DEBUG)   ?   alert("DEBUG: Data: \n" + data + "\nStatus: " + status) :   (null) );

    // Get Data..
    audio_List = new String (data);



    // Log to Console..
    ( (LOG) ?   console.log("Audio List: Loaded")   :   (null)  );

});
}

Note the Dialog Box shown by 'alert' function also shows Question Marks like the one I posted. However, if I 'alert' a Chinese Text by giving its Chinese character directly like: alert("编码");. It works fine, and I think that's what you interpreted.

役に立ちましたか?

解決

Well you can try this: http://chinesenotes.com/chinese_js/chinese_js_dojo.php

<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
<title>Dojo: Hello World!</title>
<style type="text/css">
@import "/dojo/dijit/themes/tundra/tundra.css";
@import "/dojo/dojo/resources/dojo.css"
</style>
<script type="text/javascript" src="/dojo/dojo/dojo.js"
djConfig="parseOnLoad: true"></script>
<script type="text/javascript"> dojo.require("dijit.form.Button");
</script>
</head>
<body class="tundra">
<button dojoType="dijit.form.Button" id="helloButton">你好世界!</button>
</body>
</html>

You can get the source of this page: http://chinesenotes.com/chinese_js/js_examples/dojo_ex.html

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top