Re: Help needed with python unicode cgi-bin script



Hi Martin, thanks for your response. My updates are interleaved with your
response below:


What is the encoding of that file? Without a correct answer to that
question, you will not be able to achieve what you want.

I don't know for sure the encoding of the file. I'm assuming it has no
intrinsic encoding since I copied the word "año" into vim and then saved it
as the example text file called, "spanish.txt".

Possible answers are "iso-8859-1", "utf-8", "windows-1252", and "cp850"
(these all support the word "año")

Instead of seeing "año" I see "a?o".

I don't see anything here. Where do you see the question mark? Did you
perhaps run the CGI script in a web server, and pointed your web browser
to the web page, and saw the question mark in the web browser?

The cgi-bin scripts prints to stdout, i.e. to my browser, and when I use
print I see a square box where the ñ should be. When I use print repr(...) I
see 'a\xf1o'. I never see the desired 'ñ' character.


Sending "Content-type: text/html" is not enough. The web browser needs
to know what the encoding is. So you should send

Content-type: text/html; charset="your-encoding-here"

Sorry, somehow my cut and paste job into outlook missed the exact line you
had above that specifies encoding tp be set as "utf8", but it's there in my
program. Not to worry.

Use "extras/page information" in Firefox to find out what the web
browser thinks the encoding of the page is.

Firefox says the page is UTF8.

P.S. Please, stop shouting.

OK, it's just that it hurts when I've been pulling my hair out for days on
end over a single line of code. I don't want to go bald just yet.


.



Relevant Pages

  • Re: Help needed with python unicode cgi-bin script
    ... response below: ... I don't know for sure the encoding of the file. ... perhaps run the CGI script in a web server, and pointed your web browser ...
    (comp.lang.python)
  • Re: No response after clicking on the links
    ... The web browser doesn't open? ... The web browser opens but times out waiting for a response ... Usenet or to provide web-based access for Usenet-ignorant users. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: extract data from web page
    ... Isn't the response a URL page? ... how can that be different than a web browser? ... or commercial copyright infringement might lead to jail time. ...
    (comp.lang.java.programmer)
  • Re: ps - complete username
    ... No, as in point your web browser at lists.debian.org, then you don't ... > When I first saw the response to the original poster's question, ... > realize that this list does not have "Friendly and Helpful Customer ... > Yes, it takes more work on your part, but it sure makes Debian look ...
    (Debian-User)
  • RE: WSE 2.0 encoding error
    ... Microsoft MSDN Online Support Lead ... Subject: WSE 2.0 encoding error ... giberish from server service since it is output hebrew encoding response, ...
    (microsoft.public.dotnet.xml)