> It looks like your suggestions to change charset were incorrect. My example
> works equally well with charset=utf8 as it does with charset=windows-1252.
It rather looks like that you didn't follow the suggestions carefully.
In my very first message, I wrote
# Sending "Content-type: text/html"
"weheh" <[EMAIL PROTECTED]> wrote:
> Hi Duncan, thanks for the reply.
>>>
>> FWIW, the code you posted only ever attempted to set the character
>> set encoding using an html meta tag which is the wrong place to set
>> it. The encoding specified in the HTTP headers always takes
>> precedence. This
Hi Duncan, thanks for the reply.
>>
> FWIW, the code you posted only ever attempted to set the character set
> encoding using an html meta tag which is the wrong place to set it. The
> encoding specified in the HTTP headers always takes precedence. This is
> why
> the default charset setting in Ap
"weheh" <[EMAIL PROTECTED]> wrote:
> John and Martin,
>
> Thanks for your help. However, I have identified the culprit to be
> with Apache and the command:
> AddDefaultCharset utf-8
> which forces my browser to utf-8 encoding.
>
> It looks like your suggestions to change charset were incorre
John and Martin,
Thanks for your help. However, I have identified the culprit to be with
Apache and the command:
AddDefaultCharset utf-8
which forces my browser to utf-8 encoding.
It looks like your suggestions to change charset were incorrect. My example
works equally well with charset=utf
On Dec 12, 11:06 am, "weheh" <[EMAIL PROTECTED]> wrote:
> p.s. I modified the code to break things out more explicitly:
>
> #!C:/Program Files/Python23/python.exe
> import cgi, cgitb
> import sys, codecs
> import os,msvcrt
>
> cgitb.enable()
>
> print u"""Content-Type: text/html
>
> "http://www.w3
p.s. I modified the code to break things out more explicitly:
#!C:/Program Files/Python23/python.exe
import cgi, cgitb
import sys, codecs
import os,msvcrt
cgitb.enable()
print u"""Content-Type: text/html
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; >
http://www.w3.org/1999/xhtml";
> What does the browser say what the encoding of the page is?
>
> What browser are you using, and did you configure it to default to
> UTF-8 for all pages? (which you should not have done)
>
Browser is both IE and Firefox. IE is defaulting to UTF8. If I force it to
"Encoding > Western European (Wi
> Thanks for your help and kind words of encouragement. Still, what you have
> suggested doesn't seem to work, unless I'm not understanding your directive
> to encode as 'windows-1252'.
Please read John's message again. Nowhere he said you should "encode as
'windows-1252'". Instead, he said 'use
John & Martin,
Thanks for your help and kind words of encouragement. Still, what you have
suggested doesn't seem to work, unless I'm not understanding your directive
to encode as 'windows-1252'. Here's my program in full:
#!C:/Program Files/Python23/python.exe
import cgi, cgitb
import sys, code
> No what? YES, the "decode error" is complaining that the data supplied
> is NOT valid utf-8 data. So it's not utf-8, it's windows-1252, so stop
> lying to browsers: like I said, use charset="windows-1252"
I think weheh can manage to resist good advise for a long time.
Regards,
Martin
--
http:/
On Dec 12, 4:46 am, "weheh" <[EMAIL PROTECTED]> wrote:
> Hi John:
> Thanks for responding.
>
> >Look at your file using
>
> > print repr(open('c:/test/spanish.txt','rb').read())
>
> >If you see 'a\xf1o' then use charset="windows-1252"
>
> I did this ... no change ... still see 'a\xf1o'
So it's
Hi John:
Thanks for responding.
>Look at your file using
> print repr(open('c:/test/spanish.txt','rb').read())
>If you see 'a\xf1o' then use charset="windows-1252"
I did this ... no change ... still see 'a\xf1o'
>else if you see 'a\xc3\xb1o' then use charset="utf-8" else
>Based on your
import sys
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
"Jack" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Just want to make sure, how exactly are you doing that?
>
>> Thanks for the reply, Jack. I tried setting mode to
Just want to make sure, how exactly are you doing that?
> Thanks for the reply, Jack. I tried setting mode to binary but it had no
> affect.
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 11, 9:55 am, "weheh" <[EMAIL PROTECTED]> wrote:
> 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 kno
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
intrin
Thanks for the reply, Jack. I tried setting mode to binary but it had no
affect.
"Jack" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> You probably need to set stdout mode to binary. They are not by default on
> Windows.
>
>
> "weheh" <[EMAIL PROTECTED]> wrote in message
> news:
> My problem is more complex than this, but how about I boil down one sticking
> point for starters. I have a file with a Spanish word in it, "años", which I
> wish to read with:
What is the encoding of that file? Without a correct answer to that
question, you will not be able to achieve what yo
You probably need to set stdout mode to binary. They are not by default on
Windows.
"weheh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dear web gods:
>
> After much, much, much struggle with unicode, many an hour reading all the
> examples online, coding them, testing them,
Dear web gods:
After much, much, much struggle with unicode, many an hour reading all the
examples online, coding them, testing them, ripping them apart and putting
them back together, I am humbled. Therefore, I humble myself before you to
seek guidance on a simple python unicode cgi-bin script
21 matches
Mail list logo