decodeUtf16Be static method
Converts UTF-16BE bytes (the format of /ToUnicode destinations) into
text, respecting surrogate pairs.
Implementation
static String decodeUtf16Be(Uint8List bytes) {
if (bytes.isEmpty) return '';
if (bytes.length == 1) return String.fromCharCode(bytes[0]);
final units = <int>[];
for (var i = 0; i + 1 < bytes.length; i += 2) {
units.add((bytes[i] << 8) | bytes[i + 1]);
}
try {
return String.fromCharCodes(units);
} catch (_) {
return '';
}
}