Problem showing hebrew on my site.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

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

Here is the code :

      <customErrors mode="Off"/>
      <identity impersonate="true"/>

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


<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>")


    test_text.readonly = true
end sub

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

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


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 :)

Re: Problem showing hebrew on my site.

Mr. X. wrote:

Quoted text here. Click to load it

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



Re: Problem showing hebrew on my site.

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 :)

Re: Problem showing hebrew on my site.

A little mistake.
I sould write :
objStreamReader = new StreamReader(FILENAME,

Thanks, anyway.

Re: Problem showing hebrew on my site.

Quoted text here. Click to load it

File.OpenText assumes the file is UTF-8.


to your page and use:-

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

Anthony Jones - MVP ASP/ASP.NET

Site Timeline