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
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" <
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
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
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
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
> 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
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";
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
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
I'm developing a cgi-bin application that must be unicode sensitive. I'm
striving for a UTF8 implementation. I'm running python 2.3 on a development
machine (windows xp) and a server (windows xp server). Both environments are
running Apache 2.2 with the same configuration file.
The problem is t
your questions, in this example, I believe the exception was caused by
trying to do a count of the number of times a string appears in an array.
One of the strings was unicode and the other was encoded by Python by
default.
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
Hi Fredrik,
Thanks again for your feedback. I am much obliged.
Indeed, I am forced to be exteremely rigorous about decoding on the way in
and encoding on the way out everywhere in my program, just as you say. Your
advice is excellent and concurs with other sources of unicode expertise.
Followi
I'm running Python 2.3 and calling pyTTS. I've had it working forever.
Today, I ran out of disk space. After deleting some of my personal files,
for no apparent reason, pyTTS no longer runs.
For the statement
tts = pyTTS.Create()
I get the error message:
ValueError: "SAPI" not
I don't know if you found this example:
http://www.daniweb.com/code/snippet285.html
--
> I'm was wanting to format a positive integer in binary,
> and not finding it--to my surprise--I rolled my own version.
>
> Is this already in python, or have I missed it somewhere?
>
> I have Googled around
15 matches
Mail list logo