468,133 Members | 1,156 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Problem showing hebrew on my site.

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 :)
Sep 5 '08 #1
4 1919
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
Sep 5 '08 #2
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 :)
Sep 5 '08 #3
Well.
A little mistake.
I sould write :
objStreamReader = new StreamReader(FILENAME,
Encoding.GetEncoding("windows-1255"))

Thanks, anyway.
Sep 5 '08 #4
"Mr. X." <no_spam_please@nospam_please.comwrote in message
news:g9**********@news4.netvision.net.il...
>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

Sep 5 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Mr. x | last post: by
5 posts views Thread by Mr. x | last post: by
2 posts views Thread by Mr. x | last post: by
7 posts views Thread by Elie Nacache | last post: by
40 posts views Thread by Shmuel (Seymour J.) Metz | last post: by
2 posts views Thread by Zippy | last post: by
2 posts views Thread by Mitul | last post: by
4 posts views Thread by ofiras | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.