Adam Bernau
Adam Bernau

Reputation: 759

Convert a string from ISO-8859-2 to UTF-8 in the Dart language

I would like to convert a string from the ISO-8859-2 character set to the UTF-8 character set, but I can't find any solution in the Dart language. Is it possible to do it?

Upvotes: 7

Views: 1761

Answers (1)

Alexandre Ardhuin
Alexandre Ardhuin

Reputation: 76363

There's no built-in converter for ISO-8859-2 in dart:convert. So you have to implement your own codec.

You can look at the code of Latin1Codec to implement a Latin2Codec. Once ready you will be able to do :

import 'dart:convert';

final LATIN2 = new Latin2Codec();

main() {
  List<int> bytesForIso_8859_2 = ...;
  List<int> bytesForUTF8 = LATIN2.fuse(UTF8).encode(bytesForIso_8859_2);
}

Upvotes: 8

Related Questions