搜索插件、代码仓与 APP 分类

插件详情v1.7.1

enough_convert

`dart:convert` 缺少对字符编码/字符集/编解码器的支持 - ISO 8859 / 拉丁文、Windows、DOS、GBK、Big5 和 KOI8 R/U。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
5.2万
喜欢数
25
Pub 分数
150

安装插件

flutter pub add enough_convert

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Enough Convert 扩展了 Dart 内置的 `dart:convert`,支持额外的字符编码,如 ISO 8859、Windows、DOS、GBK、Big5 和 KOI8 R/U。它填补了处理国际应用中常见的旧式和非 UTF-8 文本格式时的空白。适用于解析或生成旧系统或特定地区编码的文本,此包可确保在各种环境中实现准确的数据处理。

适合场景

  • 解析使用非UTF-8编码的旧版文本文件
  • 处理区域字符集中的多语言内容
  • 在桌面和移动应用程序之间转换不同的代码页
  • 使用 DOS 或 Windows 编码处理旧系统中的数据
  • 在国际化应用程序中支持东亚文本(GBK、Big5)
  • 确保西里尔文文本(KOI8-R/U)的正确显示

主要特点

  • 支持 ISO 8859、Windows、DOS、GBK、Big5 和 KOI8 编码
  • 轻量且与所有 Flutter 平台兼容
  • 简单 API 扩展 `dart:convert`
  • 无外部依赖
  • 对旧格式的准确编码/解码
  • 跨平台一致性

适合对象

  • 与遗留数据源一起工作的开发人员
  • 需要多语言文本支持的应用程序
  • 涉及东亚或西里尔字符集的项目
  • 需要代码页转换的移动和桌面应用程序
  • 处理非UTF-8内容的国际化团队

使用建议

  • UTF-8 专用工作流不需要
  • 仅限特定的旧式编码
  • 可能需要了解目标编码标准
  • 大规模转换时性能影响虽微小但存在
  • 在处理已知的非UTF-8输入/输出时效果最佳

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Support for character encodings / charsets / codecs missing from dart:convert.

Supports the following encodings:

  • Latin / ISO 8859 encodings:
    • Latin 1 / ISO 8859-1
    • Latin 2 / ISO 8859-2
    • Latin 3 / ISO 8859-3
    • Latin 4 / ISO 8859-4
    • Latin 5 / ISO 8859-5
    • Latin 6 / ISO 8859-6
    • Latin 7 / ISO 8859-7
    • Latin 8 / ISO 8859-8
    • Latin 9 / ISO 8859-9
    • Latin 10 / ISO 8859-10
    • Latin 11 / ISO 8859-11
    • Latin 13 / ISO 8859-13
    • Latin 14 / ISO 8859-14
    • Latin 15 / ISO 8859-15
    • Latin 16 / ISO 8859-16
  • Windows Codepage Encodings:
    • Windows-1250 / cp-1250
    • Windows-1251 / cp-1251
    • Windows-1252 / cp-1252
    • Windows-1253 / cp-1253
    • Windows-1254 / cp-1254
    • Windows-1255 / cp-1255
    • Windows-1256 / cp-1256
  • DOS Codepage Encodings:
    • cp-850
  • GBK (compatible with GB-2312)
  • KOI8
    • KOI8-R
    • KOI8-U
  • Big5

Usage

Using enough_convert is pretty straight forward:

import 'package:enough_convert/enough_convert.dart';

main() {
  final codec = const Windows1252Codec(allowInvalid: false);
  final input = 'Il faut être bête quand même.';
  final encoded = codec.encode(input);
  final decoded = codec.decode([...encoded]);
  print('${codec.name}: encode "$input" to "$encoded"');
  print('${codec.name}: decode $encoded to "$decoded"');

}

Installation

Add this dependency your pubspec.yaml file:

dependencies:
  enough_convert: ^1.6.0

The latest version or enough_convert is enough_convert version.

Wait, what is this about?

Dylan (not associated with this project in any way) explains the world of text encoding quite well: Plain text? Really?

It's 2022, do we still need this?

Short answer: yes.

Long answer: yes, there are still many web pages, emails and other content out there that is encoded in various text encodings.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Null-Safety

enough_convert is null-safe from v1.0.0 onward.

License

enough_convert is licensed under the commercial friendly Mozilla Public License 2.0

所属分类

源码仓库

使用此插件的项目