Advertisement
stuppid_bot

Encode/decode text

Dec 28th, 2016
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let utf8encoder = new TextEncoder('utf-8');
  2. console.log(utf8encoder.encode('福')); // [231, 166, 143]
  3.  
  4. let win1251decoder = new TextDecoder('windows-1251');
  5. let bytes = new Uint8Array([207, 240, 232, 226, 229, 242, 44, 32, 236, 232, 240, 33]);
  6. console.log(win1251decoder.decode(bytes)); // Привет, мир!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement