encodeUtf32Be method
Produce a list of UTF-32BE encoded bytes. By default, this method produces UTF-32BE bytes with no BOM.
Implementation
Uint8List encodeUtf32Be(String str, [bool writeBOM = false]) {
var utf32CodeUnits = stringToCodepoints(str);
var encoding = Uint8List(4 * utf32CodeUnits.length + (writeBOM ? 4 : 0));
var i = 0;
if (writeBOM) {
encoding[i++] = 0;
encoding[i++] = 0;
encoding[i++] = unicodeUtfBomHi;
encoding[i++] = unicodeUtfBomLo;
}
for (var unit in utf32CodeUnits) {
encoding[i++] = (unit >> 24) & unicodeByteZeroMask;
encoding[i++] = (unit >> 16) & unicodeByteZeroMask;
encoding[i++] = (unit >> 8) & unicodeByteZeroMask;
encoding[i++] = unit & unicodeByteZeroMask;
}
return encoding;
}