MCPcopy Create free account
hub / github.com/bitpay/bitcore-message / utf16leToBytes

Function utf16leToBytes

bitcore-message.js:2049–2063  ·  view source on GitHub ↗
(str, units)

Source from the content-addressed store, hash-verified

2047}
2048
2049function utf16leToBytes (str, units) {
2050 var c, hi, lo
2051 var byteArray = []
2052 for (var i = 0; i < str.length; ++i) {
2053 if ((units -= 2) < 0) break
2054
2055 c = str.charCodeAt(i)
2056 hi = c >> 8
2057 lo = c % 256
2058 byteArray.push(lo)
2059 byteArray.push(hi)
2060 }
2061
2062 return byteArray
2063}
2064
2065function base64ToBytes (str) {
2066 return base64.toByteArray(base64clean(str))

Callers 1

ucs2WriteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected