我有一个 XHTML 网页中的 Javascript,它传递的是 UTF-8编码的字符串。它需要继续传递 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>