简体   繁体   中英

Simple web server: form post data is encoded in quoted-printable

I'm trying to implement a basic http server code to render a web form and process posted data when user hits submit. Code is hosted here: http://www.codeproject.com/Articles/137979/Simple-HTTP-Server-in-C

However I'm getting post data in quoted-printable format which I don't want to mess with. How can I make everything wrapped in UTF-8 encoding?

Maybe you can shed a light in my particular problem or you may suggest a different approach to present a web form and handle submitted data. Thank you anyways... Sample webform and post data

You are mixing apples and oranges. The content transfer encoding encapsulates character data in a robust wrapper which escapes any characters with significance on the protocol level. This is regardless of the character set in the data. Inside the quoted-printable data, you could find character data in any character set (or binary data, though then base64 is usually the content transfer encoding of choice).

So to reiterate, you don't get an either/or choice -- character data you receive will have a content transfer encoding (which could be transparent; MIME calls this "binary", though the "8bit" and "7bit" content transfer encodings are also transparent, albeit only suitable for certain constrained types of data) and a character encoding (which could be "US-ASCII" aka plain old 7-bit character data with a very restricted character repertoire, or "ISO-8859-1" which is 8-bit and thus has a slightly larger repertoire, but still restricted; or one of the Unicode encodings, such as "UTF-8").

There really is no way for you to handle HTTP without also handling this aspect of MIME.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM