https://github.com/amake/flutter_charset_detector
Flutter plugin that detects the charset (encoding) of text bytes
https://github.com/amake/flutter_charset_detector
android charset charset-detector encoding flutter ios plugin text-encoding
Last synced: 3 months ago
JSON representation
Flutter plugin that detects the charset (encoding) of text bytes
- Host: GitHub
- URL: https://github.com/amake/flutter_charset_detector
- Owner: amake
- Created: 2020-09-11T06:55:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-26T22:10:04.000Z (3 months ago)
- Last Synced: 2025-03-16T07:22:22.484Z (3 months ago)
- Topics: android, charset, charset-detector, encoding, flutter, ios, plugin, text-encoding
- Language: Dart
- Homepage: https://pub.dev/packages/flutter_charset_detector
- Size: 572 KB
- Stars: 20
- Watchers: 2
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# flutter_charset_detector
Automatically detect and decode the charset (character encoding) of text bytes.
_The example app; [details](./example/README.md)_
This plugin uses native libraries derived from the universal charset detection
libraries created by Mozilla.- iOS, macOS:
[UniversalDetector2](https://cocoapods.org/pods/UniversalDetector2), a thin
wrapper around [uchardet](https://www.freedesktop.org/wiki/Software/uchardet/)
- Android:
[juniversalchardet](https://github.com/albfernandez/juniversalchardet), a Java
implementation of universalchardet
- Web: [jschardet](https://github.com/aadsm/jschardet), a JavaScript port of the
Python [chardet](https://github.com/chardet/chardet)## Supported platforms
- Android 4.1 (SDK 16) and higher
- iOS 11 and higher
- macOS 10.14 and higher
- Web (requires [TextDecoder](https://caniuse.com/textencoder) support)## Supported charsets
The detectable charsets differ by platform according to the capabilities of the
underlying library; for specifics see:- [iOS, macOS](https://gitlab.freedesktop.org/uchardet/uchardet/-/blob/v0.0.8/README.md#supported-languagesencodings)
- [Android](https://github.com/albfernandez/juniversalchardet/blob/v2.5.0/README.md#encodings-that-can-be-detected)
- [Web](https://github.com/aadsm/jschardet/blob/v3.1.0/README.md#supported-charsets)## Usage
```dart
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. '日本語'
```## See also
- [charset_converter](https://pub.dev/packages/charset_converter) if you already
know the name of the charset you want to encode/decode