0

I have an embedded web server written in C using uIP libraries, in a microcontroller, which outputs the following static text in response to an http get. It is shown below as a C literal string:

"HTTP/1.0 200 OK\r\n"
"Server: UIP/1.0 (http://www.something.com/)\r\n"
"Content-type: text\html\r\n"

Right after that comes the doctype string \ and the \ ... \</html> body of the page requested. I did not write this code, but it was handed to me. Now I try it on Opera, Firefox, and Internet Explorer. The entire webpage is using Ansi/C and no special strings or bytes. But it loads and displays properly only on Opera. For some reason this particular uIP based web-browser will not render on IE 8 or Firefox.

![alt text][1]

What can I add to the http headers to make my micro-web-server encoding of basic/default C/ansi codepage be detected properly for all browsers, and not just opera?

Warren P
  • 65,725
  • 40
  • 181
  • 316

1 Answers1

4

Try to replace your static text to this one:

"HTTP/1.0 200 OK\r\n"
"Server: UIP/1.0 (http://www.something.com/)\r\n"
"Content-type: text/html; charset=utf-8\r\n"

NOTE : the backslash ('\') character is an esacpe character, in your static string, you did "\h" with your "text\html"

NOTE : The "charset=utf-8" part is only useful if your files are utf-8 encode

Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
  • This is it. except it turns out I need charset=iso-8859-1 (latin1). – Warren P Jun 30 '10 at 23:55
  • I think it's just BRILLIANT that this worked fine with Opera but nobody else, but that suddenly the latest browsers change their default encode-detection algorithms. – Warren P Jun 30 '10 at 23:56
  • yes, ISO-8859-1 if your files are latin1 encoded (mostly in Windows). Though ISO-8859-1 doesn't support foreign characters without using html entities and char codes; this is why using utf-8 is far better. Glad it worked :) – Yanick Rochon Jul 01 '10 at 01:44