I'm trying to parse this RSS feed's XML response (its content is in Hebrew): https://www.foodsdictionary.co.il/rss/recipes.xml
In order to do that I make an HTTP request:
final response = await http.get(
"https://www.foodsdictionary.co.il/rss/recipes.xml"
);
My problem is that instead of getting the response with its original content, I get it with gibberish (within the body attribute):
<?xml version="1.0" encoding="windows-1255"?>
<rss version="2.0">
<channel>
<title>FoodsDictionary - ëì äîúëåðéí</title>
<link>https://www.foodsdictionary.co.il/Recipes/Index.php</link>
<description>ëì äîúëåðéí áòøåõ äàåëì åäîúëåðéí</description>
<language>he</language>
<copyright>FoodsDictionary 2020</copyright>
<lastBuildDate>Sun, 22 Mar 2020 22:30:01 +0200</lastBuildDate>
<category>òøåöé àåëì åîúëåðéí</category>
<image>
<url>https://storage.googleapis.com/st2.foodsd.co.il/Images/logo-v3.0.png</url>
<title>ëì äîúëåðéí</title>
<link>https://www.foodsdictionary.co.il/Recipes/Index.php</link>
</image>
<item>
<title>òåâú ùéù ôøâ èáòåðéú</title>
<link>https://www.foodsdictionary.co.il/Recipes/9807</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9807-LZ1J5wAvK52tekTG.jpg</image>
<description>äéà øëä åàååøéøéú (åáøåø ùèáòåðéú), òùéøä áèòí åáîø÷îéí, îúå÷ä áîéãä îãåé÷ú åîùàéøä èòí ùì òåã. äéà îúàéîä áîéåçã ìçâ ôåøéí, àáì ìà ø÷!</description>
<category>îúëåðéí ìèáòåðééí</category>
<guid>recipes-9807</guid>
<pubDate>Sun, 22 Mar 2020 00:21:56 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9807-LZ1J5wAvK52tekTG.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>÷éùåàéí áîéìåé áùø åàåøæ</title>
<link>https://www.foodsdictionary.co.il/Recipes/9798</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9798-On8E3awozYENNIed.jpg</image>
<description>÷éùåàéí îîåìàéí áúòøåáú ùì áùø åàåøæ áøåèá àãåí</description>
<category>áùø</category>
<guid>recipes-9798</guid>
<pubDate>Sat, 21 Mar 2020 23:44:47 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9798-On8E3awozYENNIed.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>ñìè çöéì áéåâåøè</title>
<link>https://www.foodsdictionary.co.il/Recipes/9800</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9800-h7atirCxHlvl0NaA.jpg</image>
<description>ñìè çöéìéí îèåâðéí òì îöò ùì éåâåøè, áæéìåó èçéðä åáúåñôú çúéëåú èåøèééä îèåâðåú - ñìè îøòðï åîéåçã ùàúí çééáéí ìðñåú</description>
<category>îúëåðéí ìöîçåðééí</category>
<guid>recipes-9800</guid>
<pubDate>Tue, 10 Mar 2020 14:26:10 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9800-h7atirCxHlvl0NaA.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>ôéúåú àôåéåú áúðåø</title>
<link>https://www.foodsdictionary.co.il/Recipes/9799</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9799-fbNuRqZiMwvCUHS2.jpg</image>
<description>ôéúåú áéúéåú îèøéôåú áúðåø îáö÷ ðôìà å÷ì ìäëðä - îäéåí ëáø ìà ÷åðéí ôéúåú áîàôééä!</description>
<category>ìçîéí</category>
<guid>recipes-9799</guid>
<pubDate>Tue, 10 Mar 2020 13:53:09 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9799-fbNuRqZiMwvCUHS2.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>òåâú ÷å÷åñ åù÷ãéí</title>
<link>https://www.foodsdictionary.co.il/Recipes/9797</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9797-5utDwTeFrlcKWBfv.jpg</image>
<description>òåâú ÷å÷åñ åù÷ãéí áñéø ôìà ùëéó ìäúòðâ òìéä áñåô"ù</description>
<category>òåâåú</category>
<guid>recipes-9797</guid>
<pubDate>Mon, 09 Mar 2020 22:18:23 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9797-5utDwTeFrlcKWBfv.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>ñìè çöéì ÷ìåé òí èçéðä åöðåáøéí</title>
<link>https://www.foodsdictionary.co.il/Recipes/9796</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9796-uAdjib2RVUX2wS4p.jpg</image>
<description>ñìè çöéì ÷ìåé ùëì éùøàìé àåäá áúåñôú èçéðä åöðåáøéí - äëé èòéí ìäúòðâ òì äñìè äæä òí ìçí áöã</description>
<category>îúëåðéí ìèáòåðééí</category>
<guid>recipes-9796</guid>
<pubDate>Mon, 09 Mar 2020 17:55:58 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9796-uAdjib2RVUX2wS4p.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>òåâéåú àåæðé ôéì ùå÷åìã</title>
<link>https://www.foodsdictionary.co.il/Recipes/9795</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9795-7T5pMyV6U8LuVZa6.jpg</image>
<description>òåâéåú ñôéøìä îáö÷ òìéí (òåâéåú àåæðé ôéì) áîéìåé îîøç ùå÷åìã - äòåâéåú äëé èòéîåú ùéìãéí äëé àåäáéí</description>
<category>îúëåðé éìãéí</category>
<guid>recipes-9795</guid>
<pubDate>Mon, 09 Mar 2020 17:27:34 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9795-7T5pMyV6U8LuVZa6.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>÷øåàñåï ù÷ãéí ãì ôçîéîä</title>
<link>https://www.foodsdictionary.co.il/Recipes/9759</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9759-3vnUv2cNelqJit6D.jpg</image>
<description>÷øåàñåï ù÷ãéí òí úçìéó ñåëø åáö÷ îâáéðú îåöøìä å÷îç ù÷ãéí ùîúàéí ìîàîöéí úæåðä ÷èåâðéú áùì äéåúå ãì áôçîéîåú</description>
<category>îúëåðéí ìñåëøúééí</category>
<guid>recipes-9759</guid>
<pubDate>Thu, 05 Mar 2020 15:13:41 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9759-3vnUv2cNelqJit6D.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>òåâú ôøâ, ÷å÷åñ åùå÷åìã èáòåðéú</title>
<link>https://www.foodsdictionary.co.il/Recipes/9790</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9790-WlxLvwQbbXoQCKQS.jpg</image>
<description>àåäáé äôøâ, äòåâä äæàú òáåøëí! äéà èòéîä áîéåçã, ìà îúå÷ä îãé åáòìú îø÷í àååøéøé åðîñ áôä. öòéøé äáéú àéðí îàåäáé äôøâ, åáæëåú äîøàä äîæîéï äí èòîå. äçì îäéåí àéï éåúø îúðâãé ôøâ àöìðå... àú äîúëåï äî÷åøé éöøä äàçééðéú äîåëùøú ùìé, òãé ëäï. òøëúé ùéðåééí áëãé ùéúàéîå ìîùôçä - ùéðéúé ëîåéåú åäçìôúé îöøëéí: ùéðéúé àú ñåâ äùîï, äôçúúé áñåëø, åéúøúé òì äàâåæéí åôåãéðâ äåðéì, äåñôúé ÷øí ÷å÷åñ ùìà äéä áîúëåï, ëîåú ðåñôú ùì ÷å÷åñ èçåï åìéîåï, åàú äâðàù äëðúé ò"ô äîúëåï äøâéì ùìé. äîúëåï äîåôéò ôä äåà òí äùéðåééí ùòøëúé!</description>
<category>îúëåðéí ìèáòåðééí</category>
<guid>recipes-9790</guid>
<pubDate>Thu, 05 Mar 2020 14:52:37 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9790-WlxLvwQbbXoQCKQS.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>òåâú àåëîðéåú èáòåðéú</title>
<link>https://www.foodsdictionary.co.il/Recipes/9789</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9789-2nL6H41OEaiuSaxs.jpg</image>
<description>òåâú àåëîðéåú èáòåðéú òí àâåæé îìê, úîøéí åàâåæé ÷ùéå - èòéîä áèéøåó, îæéðä åéôä!</description>
<category>îúëåðéí ìèáòåðééí</category>
<guid>recipes-9789</guid>
<pubDate>Thu, 05 Mar 2020 14:18:07 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9789-2nL6H41OEaiuSaxs.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>àåæðé äîï áîéìåé îîøç ìåèåñ</title>
<link>https://www.foodsdictionary.co.il/Recipes/9786</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9786-bfKmYiv4C3e3APJB.jpg</image>
<description>àåæðé äîï ìåèåñ îôð÷åú áîéåçã ìçâ ôåøéí îáö÷ ôøéê òí îîøç ùëåìí àåäáéí</description>
<category>îàôéí</category>
<guid>recipes-9786</guid>
<pubDate>Tue, 03 Mar 2020 12:40:24 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9786-bfKmYiv4C3e3APJB.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
<item>
<title>òåâú úôåæ åøéáú úåú àéùéú áöéôåé øåùä ìáï</title>
<link>https://www.foodsdictionary.co.il/Recipes/9785</link>
<image>https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9785-EqoNsUC0Off8c6t8.jpg</image>
<description>òåâú úôåæéí àéùéú áîéìåé øéáú úåúéí åáöéôåé ùå÷åìã ìáï îåîñ òí áøñ àâåæéí</description>
<category>òåâåú</category>
<guid>recipes-9785</guid>
<pubDate>Tue, 03 Mar 2020 12:13:37 +0200</pubDate>
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://st1.foodsd.co.il/Images/Recipes/s/Recipe-9785-EqoNsUC0Off8c6t8.jpg" width="142" height="107" medium="image" type="image/jpeg"></media:content>
</item>
</channel>
</rss>
My goal is to parse this XML's contents into a list, but I need the proper Hebrew characters for it.
How can I fix it?
If you just want a simple solution, use a lookup table - to turn the range 0x80-0xff
into their unicode equivalents. See code below. If you want to re-use this a lot, consider writing your own codec along the lines of UTF8Codec
or Latin1Codec
.
import 'package:http/http.dart' as http;
void main() async {
final response = await http.get(
'https://www.foodsdictionary.co.il/rss/recipes.xml',
);
var bytes = response.bodyBytes;
var length = bytes.length;
var codes = List<int>(length);
for (var i = 0; i < length; i++) {
var byte = bytes[i];
codes[i] = byte < 0x80 ? byte : table[byte - 0x80];
}
print(String.fromCharCodes(codes));
}
var table =
[
0x20AC, //EURO SIGN
0xFFED, //UNDEFINED
0x201A, //SINGLE LOW-9 QUOTATION MARK
0x0192, //LATIN SMALL LETTER F WITH HOOK
0x201E, //DOUBLE LOW-9 QUOTATION MARK
0x2026, //HORIZONTAL ELLIPSIS
0x2020, //DAGGER
0x2021, //DOUBLE DAGGER
0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //PER MILLE SIGN
0xFFED, //UNDEFINED
0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0x2018, //LEFT SINGLE QUOTATION MARK
0x2019, //RIGHT SINGLE QUOTATION MARK
0x201C, //LEFT DOUBLE QUOTATION MARK
0x201D, //RIGHT DOUBLE QUOTATION MARK
0x2022, //BULLET
0x2013, //EN DASH
0x2014, //EM DASH
0x02DC, //SMALL TILDE
0x2122, //TRADE MARK SIGN
0xFFED, //UNDEFINED
0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0x00A0, //NO-BREAK SPACE
0x00A1, //INVERTED EXCLAMATION MARK
0x00A2, //CENT SIGN
0x00A3, //POUND SIGN
0x20AA, //NEW SHEQEL SIGN
0x00A5, //YEN SIGN
0x00A6, //BROKEN BAR
0x00A7, //SECTION SIGN
0x00A8, //DIAERESIS
0x00A9, //COPYRIGHT SIGN
0x00D7, //MULTIPLICATION SIGN
0x00AB, //LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //NOT SIGN
0x00AD, //SOFT HYPHEN
0x00AE, //REGISTERED SIGN
0x00AF, //MACRON
0x00B0, //DEGREE SIGN
0x00B1, //PLUS-MINUS SIGN
0x00B2, //SUPERSCRIPT TWO
0x00B3, //SUPERSCRIPT THREE
0x00B4, //ACUTE ACCENT
0x00B5, //MICRO SIGN
0x00B6, //PILCROW SIGN
0x00B7, //MIDDLE DOT
0x00B8, //CEDILLA
0x00B9, //SUPERSCRIPT ONE
0x00F7, //DIVISION SIGN
0x00BB, //RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //VULGAR FRACTION ONE QUARTER
0x00BD, //VULGAR FRACTION ONE HALF
0x00BE, //VULGAR FRACTION THREE QUARTERS
0x00BF, //INVERTED QUESTION MARK
0x05B0, //HEBREW POINT SHEVA
0x05B1, //HEBREW POINT HATAF SEGOL
0x05B2, //HEBREW POINT HATAF PATAH
0x05B3, //HEBREW POINT HATAF QAMATS
0x05B4, //HEBREW POINT HIRIQ
0x05B5, //HEBREW POINT TSERE
0x05B6, //HEBREW POINT SEGOL
0x05B7, //HEBREW POINT PATAH
0x05B8, //HEBREW POINT QAMATS
0x05B9, //HEBREW POINT HOLAM
0xFFED, //UNDEFINED
0x05BB, //HEBREW POINT QUBUTS
0x05BC, //HEBREW POINT DAGESH OR MAPIQ
0x05BD, //HEBREW POINT METEG
0x05BE, //HEBREW PUNCTUATION MAQAF
0x05BF, //HEBREW POINT RAFE
0x05C0, //HEBREW PUNCTUATION PASEQ
0x05C1, //HEBREW POINT SHIN DOT
0x05C2, //HEBREW POINT SIN DOT
0x05C3, //HEBREW PUNCTUATION SOF PASUQ
0x05F0, //HEBREW LIGATURE YIDDISH DOUBLE VAV
0x05F1, //HEBREW LIGATURE YIDDISH VAV YOD
0x05F2, //HEBREW LIGATURE YIDDISH DOUBLE YOD
0x05F3, //HEBREW PUNCTUATION GERESH
0x05F4, //HEBREW PUNCTUATION GERSHAYIM
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0x05D0, //HEBREW LETTER ALEF
0x05D1, //HEBREW LETTER BET
0x05D2, //HEBREW LETTER GIMEL
0x05D3, //HEBREW LETTER DALET
0x05D4, //HEBREW LETTER HE
0x05D5, //HEBREW LETTER VAV
0x05D6, //HEBREW LETTER ZAYIN
0x05D7, //HEBREW LETTER HET
0x05D8, //HEBREW LETTER TET
0x05D9, //HEBREW LETTER YOD
0x05DA, //HEBREW LETTER FINAL KAF
0x05DB, //HEBREW LETTER KAF
0x05DC, //HEBREW LETTER LAMED
0x05DD, //HEBREW LETTER FINAL MEM
0x05DE, //HEBREW LETTER MEM
0x05DF, //HEBREW LETTER FINAL NUN
0x05E0, //HEBREW LETTER NUN
0x05E1, //HEBREW LETTER SAMEKH
0x05E2, //HEBREW LETTER AYIN
0x05E3, //HEBREW LETTER FINAL PE
0x05E4, //HEBREW LETTER PE
0x05E5, //HEBREW LETTER FINAL TSADI
0x05E6, //HEBREW LETTER TSADI
0x05E7, //HEBREW LETTER QOF
0x05E8, //HEBREW LETTER RESH
0x05E9, //HEBREW LETTER SHIN
0x05EA, //HEBREW LETTER TAV
0xFFED, //UNDEFINED
0xFFED, //UNDEFINED
0x200E, //LEFT-TO-RIGHT MARK
0x200F, //RIGHT-TO-LEFT MARK
0xFFED, //UNDEFINED
];