Problem showing hebrew on my site.

M

Mr. X.

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

J.O. Aho

Mr. X. said:
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?
 
M

Mr. X.

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

Mr. X.

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

Thanks, anyway.
 
A

Anthony Jones

Mr. X. said:
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));
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top