flutter_charset_detector

自动检测和解码文本字节的字符集(字符编码)。

flutter_charset_detector

此插件使用源自Mozilla创建的通用字符集检测
库的原生库。

支持的平台

  • Android 4.1(SDK 16)及更高版本
  • iOS 9及更高版本

支持的字符集

根据底层库的功能,可检测的字符集因平台而异;具体请参阅
https://github.com/amake/flutter_charset_detector

用法

import 'package:flutter_charset_detector/flutter_charset_detector.dart';

Uint8List bytes = getBytes(); // bytes with unknown encoding
DecodingResult result = CharsetDetector.autoDecode(bytes);
print(result.charset); // => e.g. 'SHIFT_JIS'
print(result.string); // => e.g. '日本語'

GitHub

https://github.com/amake/flutter_charset_detector