encode_UTF16 function

dynamic encode_UTF16(
  1. dynamic v
)

Convert a JavaScript string to UTF16-BE. @param {string} @returns {Array}

Implementation

encode_UTF16(v) {
    var b = [];
    for (var i = 0; i < v.length; i += 1) {
        var codepoint = v.charCodeAt(i);
        b[b.length] = (codepoint >> 8) & 0xFF;
        b[b.length] = codepoint & 0xFF;
    }

    return b;
}