Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js string to bytes

function strToUtf16Bytes(str) {
  const bytes = [];
  for (ii = 0; ii < str.length; ii++) {
    const code = str.charCodeAt(ii); // x00-xFFFF
    bytes.push(code & 255, code >> 8); // low, high
  }
  return bytes;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #string #bytes
ADD COMMENT
Topic
Name
9+3 =