IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Foreign Characters in Python source
In some text I'm filtering with Python script, I got a line that goes something like:
\n   postDesc = postDesc.replace("\ufffd\ufffd", "\ufffd")\n

Works fine for what I want, but Python gives me a warning along the lines of:
sys:1: DeprecationWarning: Non-ASCII character '\\xc3' in file D:\\Python\\ltu-index.py on line 3112, but no encoding declared; see [link|http://www.python.org/peps/pep-0263.html|http://www.python.org/peps/pep-0263.html] for details

Ok, so it's just a warning, but kind of annoying. I can't make out anything useful from the PEP (though I'm not very patient in these matters).

So is there a way to get these characters with the 8th bit set to be accepted by the Python compiler sans the warning?
New Declare Encoding of UTF-8
--
[link|mailto:greg@gregfolkert.net|greg],
[link|http://www.iwethey.org/ed_curry|REMEMBER ED CURRY!] @ iwethey

[link|http://it.slashdot.org/comments.pl?sid=134485&cid=11233230|"Microsoft Security" is an even better oxymoron than "Miltary Intelligence"]
No matter how much Microsoft supporters whine about how Linux and other operating systems have just as many bugs as their operating systems do, the bottom line is that the serious, gut-wrenching problems happen on Windows, not on Linux, not on Mac OS. -- [link|http://www.eweek.com/article2/0,1759,1622086,00.asp|source]
New Got it, thanks.
#!/usr/local/bin/python
# -*- coding: UTF-8 -*-
New Use unicode strings instead
The declaration Greg pointed out is only necessary if your *identifiers* need unicode. If all your unicode is safely tucked away inside of strings, use u"Pe\\xf1asco" or u"Pe\\u00f1asco". The u-prefix makes them unicode objects, as opposed to string objects. Almost all builtin and library funcs will handle them properly, including .replace().

[link|http://docs.python.org/lib/typesseq.html|http://docs.python.org/lib/typesseq.html]

[edit: added link to docs]
Expand Edited by FuManChu Jan. 28, 2005, 01:21:54 AM EST
     Foreign Characters in Python source - (ChrisR) - (3)
         Declare Encoding of UTF-8 -NT - (folkert) - (1)
             Got it, thanks. - (ChrisR)
         Use unicode strings instead - (FuManChu)

Holy String Unravelling, Batman!
68 ms