Uint8Array

    Node.js의 문자열과 바이트 배열 (Uint8Array, Buffer)

    일반적으로 영어 알파벳, 숫자, 특수 기호는 1byte, 한글은 2byte의 크기를 가진다. (utf-8) ES2018부터는 TextEncoder()를 사용할 수 있다. 문자열을 Uint8Array으로 변환하기 const utf8Encode = new TextEncoder(); const encode = utf8Encode.encode('aaaabbbbccccdddd'); console.log(encode); /* Uint8Array(16) [ 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 100, 100, 100, 100 ] */ // 다시 문자열로 const utf8Decode = new TextDecoder(); console.log(utf8Decode.dec..