download Farsi from MySQL database & ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shiesl
    New Member
    • Jul 2010
    • 6

    download Farsi from MySQL database & ASP

    This is strange and I've been knocking myself out with it. I have a utf8 character set database storing English and Farsi characters. When displayed via a web browser and through MySQL queries in the MySQL shell all characters are displayed properly. However, when retrieving data via ASP all of the non-English characters come out as question marks, e.g., "?". (If I look at non-downloaded Farsi characters via my web browser they are fine. If I look at the database characters with phpMyAdmin - 2.11.6 they are fine. It's only when I've downloaded them while in the browser that they become ? marks. )

    I have:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    in the header and:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd" dir="rtl" lang="fa">

    before the header.

    I also have

    <p dir="rtl" lang="fa"> </p>

    around the Farsi string downloaded.

    If I did not see the Farsi characters on the webpage without the download - or the Farsi characters in the database I could understand it. As it is I've tried everything I can think of - and somethings I even know are wrong - with no results. I expect it's something easy, but I cannot find it.

    Thanks to all.

    Rick
  • Shiesl
    New Member
    • Jul 2010
    • 6

    #2
    I just tried the same thing with Danish. The result was that the special Danish characters, like æ, å, ä, ø, ö, did not work. Rather they showed up as a Question Mark with a black rectangle on a corner. As opposed to a regular Question Mark with the Farsi.

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      this question comes up every once in a while, and I've never seen a rigorous solution. For roman-based alphabets (like Danish) there are always special HTML characters you can use, and it is fairly easy to replace characters with their corresponding html character codes. Unfortunately, this approach won't work for Farsi.

      I suspect that although you set the HTML page as UTF-8, you didn't set the ASP page to UTF-8
      Code:
      Response.ContentType = "text/html"
      Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
      Response.CodePage = 65001
      Response.CharSet = "UTF-8"
      Let me know if this solves your problem, otherwise, try this to troubleshoot: Make a very simple html page with a small amount of Farsi identical to what you should see from the db. Pull up the asp page, save it as a text file, and open both the files bitwise so you can see the actual bits for each character. Does the asp page have the right bitwise character codes?

      Jared
      Last edited by jhardman; Jul 16 '10, 04:18 PM. Reason: clarify

      Comment

      • Shiesl
        New Member
        • Jul 2010
        • 6

        #4
        I tried your first suggestion. It's a little better. Now I get:

        من فکر Ù…ÛŒ کنم ظواهر بسیار اهمیت دارند. من انرژی زیادی را صرف Ù…ÛŒ کنم تا ظاهری خوب را در همه جنبه های زندگی ام Ùˆ Ù¾ÛŒØ´Ø§Ù…Ø¯Ù‡Ø §ÛŒØ´ ایجاد Ú©Ù†Ù

        rather than ? marks.

        I feel really dumb on the second suggestion. Where can I find a program to open the files bitwise for a Macintosh? I've looked on the 'net and with my regular programs and have not found out.

        Thanks again.

        Comment

        • Shiesl
          New Member
          • Jul 2010
          • 6

          #5
          Originally posted by Shiesl
          I tried your first suggestion. It's a little better. Now I get:

          من فکر Ù…ÛŒ کنم ظواهر بسیار اهمیت دارند. من انرژی زیادی را صرف Ù…ÛŒ کنم تا ظاهری خوب را در همه جنبه های زندگی ام Ùˆ Ù¾ÛŒØ´Ø§Ù…Ø¯Ù‡Ø §ÛŒØ´ ایجاد Ú©Ù†Ù

          rather than ? marks.

          I feel really dumb on the second suggestion. Where can I find a program to open the files bitwise for a Macintosh? I've looked on the 'net and with my regular programs and have not found out.

          Thanks again.
          Now that's interesting. The above was with the Farsi characters. I just tried it with the Danish and it works with them. One down and one to go. Thanks greatly.

          Rick

          Comment

          • Shiesl
            New Member
            • Jul 2010
            • 6

            #6
            It's working!!!!! Smile.

            Thanks all.

            Comment

            • jhardman
              Recognized Expert Specialist
              • Jan 2007
              • 3405

              #7
              Originally posted by Shiesl
              It's working!!!!! Smile.

              Thanks all.
              so what was the final solution?

              Comment

              • jhardman
                Recognized Expert Specialist
                • Jan 2007
                • 3405

                #8
                Originally posted by Shiesl
                I tried your first suggestion. It's a little better. Now I get:

                من فکر Ù…ÛŒ کنم ظواهر بسیار اهمیت دارند. من انرژی زیادی را صرف Ù…ÛŒ کنم تا ظاهری خوب را در همه جنبه های زندگی ام Ùˆ Ù¾ÛŒØ´Ø§Ù…Ø¯Ù‡Ø §ÛŒØ´ ایجاد Ú©Ù†Ù

                rather than ? marks.

                I feel really dumb on the second suggestion. Where can I find a program to open the files bitwise for a Macintosh? I've looked on the 'net and with my regular programs and have not found out.

                Thanks again.
                by the way, last time I needed to open a file bitwise I wrote a java program to do it. I've also successfully made an ASP script to do that.

                Jared

                Comment

                • Shiesl
                  New Member
                  • Jul 2010
                  • 6

                  #9
                  The answer!

                  I"m not sure there is one answer as I made a number of changes. Here are the changes:

                  • Added "<%@ CodePage = 65001 %>" as the first line of the file. I'm not sure this was needed and have not tested, yet, what happens if I remove it.
                  • Changed:

                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                  "http://www.w3.org/TR/html4/loose.dtd" dir="rtl" lang="fa">

                  to

                  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                  "http://www.w3.org/TR/html4/loose.dtd">

                  on the second/third line.

                  • Added

                  Response.CharSe t = "utf-8"
                  Response.CodePa ge = 1252

                  after the first ASP, e.g,. "<%" in the Body. Another option might be:

                  Response.Conten tType = "text/html"
                  Response.AddHea der "Content-Type", "text/html;charset=UT F-8"
                  Response.CodePa ge = 1252
                  Response.CharSe t = "UTF-8"

                  and the "1252" possibly could be changed to "65001".

                  • Changed:

                  strConnString = "Driver={My SQL ODBC 3.51 Driver}; SERVER=localhos t;" & "DATABASE=PIPII ; UID=m[/INDENT][/INDENT]ike; PASSWORD=rick; OPTION=3"

                  to

                  strConnString = "Driver={My SQL ODBC 3.51 Driver}; SERVER=localhos t;" & "DATABASE=PIPII ; UID=mike; PASSWORD=rick; OPTION=3;Stmt=S ET CHARACTER SET utf8"

                  when I open the database to get the data.

                  I think that's it. Thanks all.

                  Rick

                  Comment

                  Working...