-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
This is more of a question rather than an issue, but hopefully someone can answer me.
I am loading the HTML from a Russian webpage using http package into a String variable like so:
String html = await http.Client().get(Uri.parse(url)).body;The website encoding is Windows1251. So for example html variable can have text such as "Êàêèå". This is what I see when I print the variable.
So my question is: How do I convert that string to Cyrillic characters in Unicode encoding which should result in "Какие"?
I tried this:
import 'dart:convert';
import 'package:enough_convert/enough_convert.dart';
void main() {
final html = "Êàêèå";
final encoded = const Windows1251Codec().encode(html);
final converted = const Utf8Codec().decode(encoded);
print(converted);
}But I get an error on this line: final encoded = const Windows1251Codec().encode(html);:
FormatException: Invalid value in input: "Ê" / (202) at index 0 of "Êàêèå"
Essentially what I would like to do is to convert "Êàêèå" to "Какие". You can do this on the website https://convertcyrillic.com. Here is the screenshot:
So how do I do this programmatically in Dart?
Metadata
Metadata
Assignees
Labels
No labels