You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';
voidmain() {
final html ="Êàêèå";
final encoded =constWindows1251Codec().encode(html);
final converted =constUtf8Codec().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?
The text was updated successfully, but these errors were encountered:
Turns out I have to encode the string using Latin1 encoder first, and then decode it using Windows1251 codec:
import'package:enough_convert/enough_convert.dart';
voidmain() {
final html ="Êàêèå";
final encoded =constLatin1Codec().encode(html);
final converted =constWindows1251Codec().decode(encoded);
print(converted);
}
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 aString
variable like so:The website encoding is
Windows1251
. So for examplehtml
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:
But I get an error on this line:
final encoded = const Windows1251Codec().encode(html);
: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?
The text was updated successfully, but these errors were encountered: