Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to convert Character codes HTML to arabic using c#

how to convert Character codes HTML to arabic using c#

Scheduled Pinned Locked Moved C#
csharphtmltutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michael nabil
    wrote on last edited by
    #1

    i have string in Arabic language but it's appear like that

    Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

    Basically I need to convert My source string to Arabic and I do it using following code: i try

    string responseXML = Encoding.UTF8.GetString(Encoding.Default.GetBytes(responseXML));

    result

    Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

    but the right result is

    string"د ج ح خ ه ع غ ف ق ث ص ض ط م ن ت ا أ ل لأ ب ي س ش ظ ز و ة ى لا ر ؤ ء ئ ذ"

    What I'm doing wrong here?

    Richard DeemingR L 2 Replies Last reply
    0
    • M michael nabil

      i have string in Arabic language but it's appear like that

      Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

      Basically I need to convert My source string to Arabic and I do it using following code: i try

      string responseXML = Encoding.UTF8.GetString(Encoding.Default.GetBytes(responseXML));

      result

      Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

      but the right result is

      string"د ج ح خ ه ع غ ف ق ث ص ض ط م ن ت ا أ ل لأ ب ي س ش ظ ز و ة ى لا ر ؤ ء ئ ذ"

      What I'm doing wrong here?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      You're probably using the wrong encoding. What encoding does the HTTP response declare? Content-Encoding - HTTP | MDN[^] What encoding does the XML document declare (if any)? XML Declaration - Wikipedia[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        You're probably using the wrong encoding. What encoding does the HTTP response declare? Content-Encoding - HTTP | MDN[^] What encoding does the XML document declare (if any)? XML Declaration - Wikipedia[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        M Offline
        M Offline
        michael nabil
        wrote on last edited by
        #3

        i get data from QuickBooks like this

        *أاإ ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ

        it retrain the encoding of the xml response declare is ISO-8859-1 (ISO Latin 1) like this

        Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

        i didn't find away to convert it to Arabic direct so i convert it to html encode like this

        Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

        now i want to convert html encode to Arabic i don't know how can help me thanks

        Richard DeemingR 1 Reply Last reply
        0
        • M michael nabil

          i get data from QuickBooks like this

          *أاإ ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ

          it retrain the encoding of the xml response declare is ISO-8859-1 (ISO Latin 1) like this

          Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

          i didn't find away to convert it to Arabic direct so i convert it to html encode like this

          Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

          now i want to convert html encode to Arabic i don't know how can help me thanks

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          If the data is encoded using ISO-8859-1, then you can't use UTF8 to decode it. You need to specify the correct encoding:

          Encoding iso = Encoding.GetEncoding("ISO-8859-1");

          The question remains, since you already have a string, why are you decoding it to bytes simply to encode it back to a string?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • M michael nabil

            i have string in Arabic language but it's appear like that

            Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

            Basically I need to convert My source string to Arabic and I do it using following code: i try

            string responseXML = Encoding.UTF8.GetString(Encoding.Default.GetBytes(responseXML));

            result

            Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ

            but the right result is

            string"د ج ح خ ه ع غ ف ق ث ص ض ط م ن ت ا أ ل لأ ب ي س ش ظ ز و ة ى لا ر ؤ ء ئ ذ"

            What I'm doing wrong here?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Just print / display responseXML before tinkering with it. Your "result" is single byte characters where the "right result" (and input apparently) happens to be "double-byte" characters.

            It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups