搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案