我遇到的问题是,我得到的 JS-Objects 的字段如下......
处理转换的代码如下所示(并且在一般情况下正常工作......)
public arrayBufferToString(arrayBuffer : Uint8Array) : string {
var str : string = String.fromCharCode.apply(null, new Uint8Array(arrayBuffer));
return str;
}
public stringToArrayBuffer(string:string) : Uint8Array {
if(typeof string === 'undefined' || string === null){
this.$log.warn('Cannot convert an undefined string');
return null;
}
var arrayBuffer : any = new ArrayBuffer(string.length);
var buffer : Uint8Array = new Uint8Array(arrayBuffer);
for (var i : number = 0, stringLength : number = string.length; i < stringLength; i++) {
buffer[i] = string.charCodeAt(i);
}
return buffer;
}
然而,在这些情况下,我有这样的输入:“title”:“действительный有效なដែលមានសុពលភាព有效有效માન્યમાבתוקף”和输出,在将其格式化回字符串后,如“title”“45AB28” =K9 ¹j¶»¶ HH®¾¨Í¯®¾ÑêÕçã"
你知道为什么会这样吗?谢谢!