decoded property

String get decoded

Decode to Dart string, handling PDF encoding.

Implementation

String get decoded {
  if (value.startsWith('\xfe\xff')) {
    // UTF-16BE BOM
    final bytes = value.codeUnits;
    final buffer = StringBuffer();
    for (int i = 2; i < bytes.length - 1; i += 2) {
      buffer.writeCharCode((bytes[i] << 8) | bytes[i + 1]);
    }
    return buffer.toString();
  }
  return _decodePdfDocEncoding(value);
}