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

A

Abe Simpson

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
 
J

Joerg Jooss

Abe said:
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,
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top