encodeUtf16le function
Implementation
List<int> encodeUtf16le(String str, [bool writeBOM = false]) {
var utf16CodeUnits = _stringToUtf16CodeUnits(str);
var encoding = <int>[];
//List<int>(/* 2 * utf16CodeUnits.length + (writeBOM ? 2 : 0) */);
if (writeBOM) {
encoding.add(UNICODE_UTF_BOM_LO);
encoding.add(UNICODE_UTF_BOM_HI);
}
for (var unit in utf16CodeUnits) {
encoding.add(unit & UNICODE_BYTE_ZERO_MASK);
encoding.add((unit & UNICODE_BYTE_ONE_MASK) >> 8);
}
return encoding;
}