Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem showing hebrew on my site.

Reply
Thread Tools

Problem showing hebrew on my site.

 
 
Mr. X.
Guest
Posts: n/a
 
      09-05-2008
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


 
Reply With Quote
 
 
 
 
J.O. Aho
Guest
Posts: n/a
 
      09-05-2008
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
 
Reply With Quote
 
 
 
 
Mr. X.
Guest
Posts: n/a
 
      09-05-2008
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


 
Reply With Quote
 
Mr. X.
Guest
Posts: n/a
 
      09-05-2008
Well.
A little mistake.
I sould write :
objStreamReader = new StreamReader(FILENAME,
Encoding.GetEncoding("windows-1255"))

Thanks, anyway.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      09-05-2008
"Mr. X." <no_spam_please@nospam_please.com> wrote in message
news:g9qkiu$1pl$(E-Mail Removed)...
>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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with AJAX and Hebrew (or any other language) ofiras Javascript 2 04-02-2009 11:47 AM
Problem showing hebrew on my site. Mr. X. HTML 4 09-05-2008 08:13 AM
Jasper Reports BIDI languages (+ Hebrew) Problem friedman30@gmail.com Java 7 01-29-2007 03:05 PM
Problem POSTING hebrew letters Julia ASP General 0 04-10-2005 10:48 AM
Re: hebrew characters not showing up Stefano Mostarda ASP .Net 0 02-18-2004 01:13 PM



Advertisments