Why are these caracters not being display correct

G

Guest

Hello all,

In my code im using Response.Write(someText) to write out some Japanese text
to a new browser window. In the command window, the text is correct, but when
the browser window opens it appears as ャーã®エア抜ãÂÂ.

Why would this be so? My code is below:

Response.ClearHeaders();
Response.ClearContent();
Response.Buffer= true;
Response.AppendHeader("content-length", strResponse.Length.ToString());
Response.AppendHeader("content-disposition", "attachment;filename=Online
Form Results " + IDToDisplay.ToString()+ ".html");

Response.ContentType = "text/html";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Expires = 0;
Response.Write(strResponse);

Response.End();

Thanks all for help.

JY
 
J

Joerg Jooss

Thus wrote John,
You may not be able to cant display Japanese textbwith UTF-8 encoding.
you'll need to use a japanese charset such as

<meta http-equiv="content-type" content="text/html;
charset=Shift_JIS">

http://msdn2.microsoft.com/en-us/library/system.text.encoding.codepage
.aspx

I've never tried it but it may be
Response.ContentEncoding = Encoding.GetEncoding("SHIFT-JIS")
Regards

UTF-8 is a *Unicode* Tranformation Format and thus has no problems encoding
Japanese characters.

Cheers,
 
J

Joerg Jooss

Thus wrote Jon,
Hello all,

In my code im using Response.Write(someText) to write out some
Japanese text to a new browser window. In the command window, the text
is correct, but when the browser window opens it appears as
ャーã®ã‚¨ã‚¢æŠœã.

Why would this be so? My code is below:

Response.ClearHeaders();
Response.ClearContent();
Response.Buffer= true;
Response.AppendHeader("content-length",
strResponse.Length.ToString());

That's not the true Content-Length. Its value may be greater than the string
length.
Response.AppendHeader("content-disposition",
"attachment;filename=Online
Form Results " + IDToDisplay.ToString()+ ".html");
Response.ContentType = "text/html";
Response.ContentEncoding = System.Text.Encoding.UTF8;

Did you check whether the browser did pick up the correct encoding (UTF-8)
from the HTTP response?

Cheers,
 
J

John Timney \(MVP\)

I never knew that Joerg. Thanks for correcting me.

Regards

John Timney (MVP)
 

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,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top