Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to decode ASCII to text in dart

So I need to decode a from ASCII to text:

ex: &#1601 &#1614 &#1573 &#1616 &#1606 &#1617 &#1614 &#32 &#1649 &#1604 &#1618 &#1580& #1614 &#1606 &#1617 &#1614 &#1577 &#1614

All separated by ";"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

would be:
فَإِنَّ ٱلْجَنَّة

I looked into dart:convert package and it’s Ascii decoder it doesn’t seems to be an answer.
any thoughts

>Solution :

You need understand that &#1601 is html definition of 1601 decimal character code on ASCII table.

on Dart to get char from code you need just call
String.fromCharCode(1601) -> ف

Here is some example from your case

String str = "&#1601 &#1614 &#1573 &#1616 &#1606 &#1617 &#1614 &#32 &#1649 &#1604 &#1618 &#1580 &#1614 &#1606 &#1617 &#1614 &#1577 &#1614";
var maped = str.split(' ').map((charCode) {
    return String.fromCharCode(
        int.parse(charCode.replaceAll('&#', ''))
    );  
}).join('');
  
  print(maped);

OUTPUT:

فَإِنَّ ٱلْجَنَّةَ

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading