Package selection guidance compiled from public package information, community data, and project usage.
A lightweight Flutter package for converting text between different character encodings, leveraging the underlying platform's native encoding support. It requires no external dependencies, ensuring efficient and reliable conversion across platforms including Android, iOS, Windows, and Linux. Ideal for handling legacy or non-UTF-8 text data in applications that process internationalized content or work with diverse file formats.
Use cases
Converting legacy text files from ISO-8859-1 to UTF-8
Processing web scraping outputs with unknown encodings
Handling multilingual user input in apps
Reading configuration files with non-standard encodings
Key features
Uses native platform encoding APIs
No external dependencies
Cross-platform compatibility
Simple synchronous API
Supports common character sets
Suitable for
Apps processing international text
Data migration tools
File format parsers
Legacy system integrations
Considerations
Relies on platform-specific encoding implementations
Limited to supported encodings by the OS
No built-in fallback mechanisms
Not suitable for complex encoding detection
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Charset converter
Encode and decode charsets using platform built-in converter. This saves app package size as you don't need any external charset maps or whole libraries like iconv. This package doesn't even contain any Dart dependencies. However this comes with the dependency on the platform.
This package was originally made to help deal with this StackOverflow question and Dart's lack of support for many specific charset like GBK, Big5, Windows-125X or ISO-8859-XX.
Warning: Please note that even if charset is not present on the list, it still might work. This is because the function is not returning the full list of aliases, this is presented in the example of iOS - TIS620 does not appear on the list, but ISO 8859-11, which is actually an alias of TIS620 does. To check if charset is available use CharsetConverter.checkAvailability.
Please also note that names are platform specific and may be different.
Android comes with Java runtime, which has a built-in Charset class which has convenient encode and decode methods. All it's left to do is use channels to pass the data.
iOS can also work with charsets with CoreFoundation CFString functions fe. CFStringConvertIANACharSetNameToEncoding. We can also easily encode and decode Strings with init and data. It is a little bit cumbersome since we have to convert the values and use ported C API.
Linux can use libIconv in GLib. Since Flutter for Linux use GTK, it is pretty suitable. However, it accept a NUL terminated UTF-8 string (like C string end with\0), so in Dart side, String will be dealt by transferring into Uint8List, and add 0 at the end.
Contributing
Feel free to create issues, fix bugs, add new functionalities even if you are not sure about. Everyone is welcome!