MCPcopy Index your code
hub / github.com/feross/buffer / utf16leToBytes

Function utf16leToBytes

index.js:2043–2057  ·  view source on GitHub ↗
(str, units)

Source from the content-addressed store, hash-verified

2041}
2042
2043function utf16leToBytes (str, units) {
2044 let c, hi, lo
2045 const byteArray = []
2046 for (let i = 0; i < str.length; ++i) {
2047 if ((units -= 2) < 0) break
2048
2049 c = str.charCodeAt(i)
2050 hi = c >> 8
2051 lo = c % 256
2052 byteArray.push(lo)
2053 byteArray.push(hi)
2054 }
2055
2056 return byteArray
2057}
2058
2059function base64ToBytes (str) {
2060 return base64.toByteArray(base64clean(str))

Callers 1

ucs2WriteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected