Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net 2.0 and Javascript error using Japanese character

Status
Not open for further replies.

gal10

Programmer
Feb 13, 2008
1
US
Hi Friends,

I am using ASP.Net 2.0. Though what I m doing is very simple thing still I am not able to find the solution for that.

I have public string installMessage. I am verifying the clinet side .Net version and accordingly display the message to client and then start the installation by donwloading the selfextracted exe. Here I m using window.location.href and setting its value to exe file. Here I m displaying english or Japanese text based on the language selection.

Problem with different approaches:

1) I opted for using document.write('<%=serverVar%>') before setting window.location.href to exe file. But in case of Japanese string this throws error in browser as Japanese text may have some character which is calusing this. The error I m getting is "Unterminated string". Because of this I went for second solution as below.

2) I put one DIV tag and set its id and runat property. Then I m using this variable to set the value to installation information. Here when I run the aspx page the installation starts properly but I dont see any text on the page. If I comment the line "window.location.href" then I am able to get the text message otherwise it does not display the message. Though if I see the view source I can see the text message within the DIV tag. I m not getting what "window.location.href" doing that the page is not getting parsed properly and the text message is not coming.

Any clue about any of the above two solutions or method. Even I tried using ASP.Net server controls but the behaviour is same and I m not getting root cause of that.

Thanks and advance.

Jitendra
 
Have you tried converting the Japanese character to a Unicode number? A double quote (") is #34;, etc. I don't know if that will satisfy Javascript's difficulty handling characters beyond #150; (the limit is somewhere around there, I believe, but I'm not sure exactly where).

Lee
 
[0] If the error comes from window.location.href to set whatever, an .exe?!, I have nothing to say and it is not related to the renderment of the installmessage?

[1] Imagine you sit in front of the desktop to draft out the aspx/asp. You can save the file in utf-8 (as a reference) encoding format, which sure support most foreign characters.

[2] Then you upload to the server.

[3] In that case, you aspx/asp should have something asserting the codepage and charset if it is something of per-page-basis, rather than per-session-basis.
[3.1] In the asp page, you then have to put at the top.
[tt]
response.codepage=65001
response.charset="UTF-8"
[/tt]
In this case, in particular the response.charset, will coerse the user agents to switch to the encoding utf-8 even before it receives the page, the encoding scheme is different.
[3.2] In the hybrid layout, you may add the meta tag.
[tt]
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
[/tt]
[3.3] If the meta tag charset does not agree with response.charset server-side line, the latter will take precedence. If the response.charset is not there, the meta tag can salvage the situation.
[3.4] Now all these should come in agreement with the page saved by your editor before upload to the server ([1] and [2]). If they agree, it should be fine, in big picture generally.
[3.5] Now, the thing can get more involved if the server taking in request object, which is not in the description. Also, with misfortune, the user agent does not support that kind of charset and fall back to some others which now introduces some uncertain factors.

[4] As a general reference of this (complicated) matter, this may help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top