0

I'm using Ionic 3

 uintToString(uintArray) {
var encodedString = String.fromCharCode.apply(null, uintArray),
    decodedString = decodeURIComponent(escape(encodedString));
return decodedString;

it works very well on ionic serve command! but the problem is that when I command ionic cordova run android --device

it comes error saying cannot find name 'escape'.

how can I change uint array to utf -8 string... on ionic3?

john.P
  • 21
  • 1
  • 5

2 Answers2

0

The global escape function is deprecated, you should use encodeURI or encodeURIComponent instead.

jo_va
  • 13,504
  • 3
  • 23
  • 47
0

I'm using this to turn Uint8Array into string:

static uint2str(array: Uint8Array): string {
  const chars: string[] = [];
  for (let i = 0; i < array.length; i++) {
    chars.push(String.fromCharCode(array[i]));
  }
  return chars.join('');
}
martin
  • 93,354
  • 25
  • 191
  • 226