Converting array buffer in string
12,332
You should try something like this:
function uintToString(uintArray) {
var encodedString = String.fromCharCode.apply(null, uintArray),
decodedString = decodeURIComponent(escape(encodedString));
return decodedString;
}
Maybe this will help:
https://ourcodeworld.com/articles/read/164/how-to-convert-an-uint8array-to-string-in-javascript
Related videos on Youtube
Author by
Shifali singla
Updated on June 04, 2022Comments
-
Shifali singla almost 2 years
I am stuck in converting arraybuffer to string in typescript (angular 4 project). Any help is highly appreciated.
Code output is showing string but with this sign - �
Required Output :
PROGRAM "Digitala †rsredovisningen"
Getting Output :
PROGRAM "Digitala �rsredovisningen"
ab2str(arraybuffer) { return String.fromCharCode.apply(null, new Uint8Array(arraybuffer)); }
-
Shifali singla over 6 yearsThank you @Zinc , but Uint16Array shows output something like 䘣䅌䝇⁁ਰ倣佒則䵁∠楄楧慴慬蘠獲
-
Shifali singla over 6 yearsfunction ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } - Same code I am using, It is not working
-
David Pelayo over 6 yearsCan you post a codepen, a jsbin or similar with an example of your issue so we can help?
-
Shifali singla over 6 yearsI just found - String.fromCharCode.apply(null, [134]) - this isnt working.