Reputation: 23
I need to use iso-8859 type in flutter but the method iconv not supported, is there any other method ?
Upvotes: 1
Views: 2322
Reputation: 71653
I'd convert it to a string and then convert the string to the ISO-8859-X code page that you want, which in this case is probably ISO-8859-6 Latin/Arabic.
The convert
package (now) supports all the ISO-8859 code pages.
import "dart:convert" show utf8;
import "package:convert" show latinArabic;
...
var utf8Bytes = ...;
var string = utf8.decode(utf8Bytes);
var latinArabicBytes = latinArabic.encode(string);
You can create helper converter for that as:
final utf8ToLatinArabicConverter = utf8.decoder.fuse(latinArabic.encoder);
final utf8ToLatinARabic = utf8ToLatinArabicConverter.convert;
....
var latinArabicBytes = utf8ToLatinArabic(utf8Bytes);
Upvotes: 5