(str, units)
| 2041 | } |
| 2042 | |
| 2043 | function 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 | |
| 2059 | function base64ToBytes (str) { |
| 2060 | return base64.toByteArray(base64clean(str)) |