469,931 Members | 1,831 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Request["fieldname"] returns UTF8 but I want Unicode

Hi all,

My form file has this attribute:

<META http-equiv="Content-Type" content="text/html; charset=utf-8">

The form's action points to an .aspx file where I try to retrieve field
values as follows:

txtTextBox.Text = Request["fieldname"];

However this seems to return a UTF-8 encoded string. In classic ASP, if
would return Unicode, so that I would say

Response.Write( Server.HtmlEncode( Request("fieldname") ) ) and that would
return plain ASCII text (all those Ӓ things).

In ASP.NET, however, Server.HtmlEncode does not seem to do anything at all,
I still get UTF-8, and I need plain ASCII!

How do I convert UTF-8 to plain Unicode (UTF-16) and then to plain ASCII?

Thanks in advance.

-- Abe
Dec 13 '05 #1
1 2011
Abe Simpson wrote:
Hi all,

My form file has this attribute:

<META http-equiv="Content-Type" content="text/html; charset=utf-8">

The form's action points to an .aspx file where I try to retrieve
field values as follows:

txtTextBox.Text = Request["fieldname"];

However this seems to return a UTF-8 encoded string. In classic ASP,
if would return Unicode, so that I would say
Strings in .NET are alyways (UTF-16LE) Unicode strings.
Response.Write( Server.HtmlEncode( Request("fieldname") ) ) and that
would return plain ASCII text (all those Ӓ things).

In ASP.NET, however, Server.HtmlEncode does not seem to do anything
at all, I still get UTF-8, and I need plain ASCII!
I don't get it. UTF-8 is identical to US-ASCII in the 7 bit range, and
anything above 7 bit simply doesn't exist in ASCII. What are you trying
to achieve?
How do I convert UTF-8 to plain Unicode (UTF-16) and then to plain
ASCII?


What for? Once you have a .NET string, encoding is irrelevant. You only
need an encoding to create byte representations from strings or vice
versa.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Dec 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.