๐Ÿ“ฆ amake / flutter_charset_detector

Flutter plugin that detects the charset (encoding) of text bytes

โ˜… 20 stars โ‘‚ 14 forks ๐Ÿ‘ 20 watching
androidcharsetcharset-detectorencodingflutteriosplugintext-encoding
๐Ÿ“ฅ Clone https://github.com/amake/flutter_charset_detector.git
HTTPS git clone https://github.com/amake/flutter_charset_detector.git
SSH git clone git@github.com:amake/flutter_charset_detector.git
CLI gh repo clone amake/flutter_charset_detector
Aaron Madlon-Kay Aaron Madlon-Kay darwin v1.2.1 ea6dd78 5 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .gitignore
๐Ÿ“„ Makefile
๐Ÿ“„ README.md
๐Ÿ“„ README.md

fluttercharsetdetector

Automatically detect and decode the charset (character encoding) of text bytes.

The example app; details

This plugin uses native libraries derived from the universal charset detection libraries created by Mozilla.

  • iOS, macOS:
UniversalDetector2, a thin wrapper around uchardet
  • Android:
juniversalchardet, a Java implementation of universalchardet Python chardet

Supported platforms

  • Android 4.1 (SDK 16) and higher
  • iOS 11 and higher
  • macOS 10.14 and higher
  • Web (requires TextDecoder support)

Supported charsets

The detectable charsets differ by platform according to the capabilities of the underlying library; for specifics see:

Setup

  • Web
  • Others: no special setup required

Usage

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

know the name of the charset you want to encode/decode