我在传递 UTF-8 编码字符串的 XHTML 网页中有 Javascript。它需要继续传递 UTF-8 版本,并对其进行解码。如何解码 UTF-8 字符串以进行显示?
<script type="text/javascript">
// <![CDATA[
function updateUser(usernameSent){
var usernameReceived = usernameSent; // Current value: Größe
var usernameDecoded = usernameReceived; // Decode to: Größe
var html2id = '';
html2id += 'Encoded: ' + usernameReceived + '<br />Decoded: ' + usernameDecoded;
document.getElementById('userId').innerHTML = html2id;
}
// ]]>
</script>