Problem showing hebrew on my site.

Discussion in 'HTML' started by Mr. X., Sep 5, 2008.

  1. Mr. X.

    Mr. X. Guest

    I have a problem showing hebrew on my site.
    Please, help.

    Here is the code :

    web.config
    =======
    <configuration>
    <system.web>
    <customErrors mode="Off"/>
    <identity impersonate="true"/>
    <globalization
    requestEncoding="windows-1255"
    responseEncoding="windows-1255"
    fileEncoding="windows-1255"
    culture="he-IL"
    uiCulture="he-IL"
    />
    </system.web>
    </configuration>

    ....
    I put web.config on the main directory of the site (where there is
    index.html - main default page).

    test.aspx
    ======
    <%@ Import Namespace="System.IO" %>
    <html>

    <head>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255">
    <script runat="server" charset="windows-1255">
    sub Page_Load(sender as Object, e as EventArgs)
    Dim FILENAME as String = Server.MapPath("test.txt")

    Dim objStreamReader as StreamReader
    objStreamReader = File.OpenText(FILENAME)

    Dim contents as String = objStreamReader.ReadToEnd()

    test_text.text = contents.Replace(vbCrLf, "<br>")

    objStreamReader.Close()

    test_text.readonly = true
    end sub
    </script>
    <title>Test</title>
    </head>

    <body text = "black" bgcolor = "#ffffff">

    <form runat="server">
    <asp:textbox TextMode = "MultiLine" id = "test_text" runat="server" width =
    "300" height = "300" />
    </form>

    </body>
    </html>

    test.txt is a simple text ascii file with some Hebrew.

    The site supports dot-net (it's a windows dot net platform).
    The page is loaded correctly, except instead of Hebrew I see many question
    marks (something like : ??? ??? ??????)

    What is wrong on my code ?

    Thanks :)
     
    Mr. X., Sep 5, 2008
    #1
    1. Advertising

  2. Mr. X.

    J.O. Aho Guest

    Mr. X. wrote:

    > test.txt is a simple text ascii file with some Hebrew.
    > The site supports dot-net (it's a windows dot net platform).
    > The page is loaded correctly, except instead of Hebrew I see many question
    > marks (something like : ??? ??? ??????)
    >
    > What is wrong on my code ?


    Could it be that your text file ain't windows-1255 but some toher character
    encoding like utf-8?

    --

    //Aho
     
    J.O. Aho, Sep 5, 2008
    #2
    1. Advertising

  3. Mr. X.

    Mr. X. Guest

    test.txt is OK.

    What I see that StreamReader should be constructed with an Encoding.
    something like :
    objStreamReader = new(FILENAME, Encoding.GetEncoding("windows-1255"))

    but the above runs out of compilation errors, and I didn't find what is the
    exact syntax for that (for the rest of my code).

    Thanks :)
     
    Mr. X., Sep 5, 2008
    #3
  4. Mr. X.

    Mr. X. Guest

    Well.
    A little mistake.
    I sould write :
    objStreamReader = new StreamReader(FILENAME,
    Encoding.GetEncoding("windows-1255"))

    Thanks, anyway.
     
    Mr. X., Sep 5, 2008
    #4
  5. "Mr. X." <no_spam_please@nospam_please.com> wrote in message
    news:g9qkiu$1pl$...
    >I have a problem showing hebrew on my site.
    > Please, help.
    >
    > Here is the code :
    >
    > web.config
    > =======
    > <configuration>
    > <system.web>
    > <customErrors mode="Off"/>
    > <identity impersonate="true"/>
    > <globalization
    > requestEncoding="windows-1255"
    > responseEncoding="windows-1255"
    > fileEncoding="windows-1255"
    > culture="he-IL"
    > uiCulture="he-IL"
    > />
    > </system.web>
    > </configuration>
    >
    > ...
    > I put web.config on the main directory of the site (where there is
    > index.html - main default page).
    >
    > test.aspx
    > ======
    > <%@ Import Namespace="System.IO" %>
    > <html>
    >
    > <head>
    > <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255">
    > <script runat="server" charset="windows-1255">
    > sub Page_Load(sender as Object, e as EventArgs)
    > Dim FILENAME as String = Server.MapPath("test.txt")
    >
    > Dim objStreamReader as StreamReader
    > objStreamReader = File.OpenText(FILENAME)
    >
    > Dim contents as String = objStreamReader.ReadToEnd()
    >
    > test_text.text = contents.Replace(vbCrLf, "<br>")
    >
    > objStreamReader.Close()
    >
    > test_text.readonly = true
    > end sub
    > </script>
    > <title>Test</title>
    > </head>
    >
    > <body text = "black" bgcolor = "#ffffff">
    >
    > <form runat="server">
    > <asp:textbox TextMode = "MultiLine" id = "test_text" runat="server" width
    > = "300" height = "300" />
    > </form>
    >
    > </body>
    > </html>
    >
    > test.txt is a simple text ascii file with some Hebrew.
    >
    > The site supports dot-net (it's a windows dot net platform).
    > The page is loaded correctly, except instead of Hebrew I see many question
    > marks (something like : ??? ??? ??????)
    >
    > What is wrong on my code ?
    >


    File.OpenText assumes the file is UTF-8.


    Add:-

    <%@ Import Namespace="System.Text" %>

    to your page and use:-

    objStreamReader = new StreamReader(FILENAME, Encoding.GetEncoding(1255));



    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Sep 5, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefano Mostarda

    Re: hebrew characters not showing up

    Stefano Mostarda, Feb 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    530
    Stefano Mostarda
    Feb 18, 2004
  2. Replies:
    7
    Views:
    1,153
  3. Mr. X.

    Problem showing hebrew on my site.

    Mr. X., Sep 5, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    302
    Anthony Jones
    Sep 5, 2008
  4. Julia

    Problem POSTING hebrew letters

    Julia, Apr 10, 2005, in forum: ASP General
    Replies:
    0
    Views:
    201
    Julia
    Apr 10, 2005
  5. Mr. x

    I don't hebrew on my site.

    Mr. x, Nov 3, 2003, in forum: Javascript
    Replies:
    5
    Views:
    118
    Klaus Johannes Rusch
    Nov 4, 2003
Loading...

Share This Page