charset_normalizer_dart 0.1.0
charset_normalizer_dart: ^0.1.0 copied to clipboard
Charset detection for Dart and Flutter, ported from Python charset_normalizer.
example/charset_normalizer_dart_example.dart
// SPDX-FileCopyrightText: 2026 沉默の金 <cmzj@cmzj.org>
// SPDX-License-Identifier: MIT
import 'dart:convert';
import 'package:charset_normalizer_dart/charset_normalizer_dart.dart';
void main() {
final List<int> payload = utf8.encode(
'A clear UTF-8 example with 中文字符 for charset detection.',
);
final CharsetMatch? best = fromBytes(payload).best();
if (best == null) {
print('No text encoding detected.');
return;
}
print('Encoding: ${best.encoding}');
print('Text: $best');
}