Carl Banks wrote:
Also, note that there are some encodings unrelated to Unicode. For
example, try this:
. >>> "abcd".encode("base64")
This is an encoding between two byte strings.
Yes. This can be especially nice when you need to use restricted charsets.
I needed to use unicode objects as Zope ids
Skip Montanaro wrote:
> I started to answer, then got confused when I read the docstrings for
> unicode.encode and unicode.decode:
[snip]
It certainly is confusing. When I first started Unicoding, I pretty
much stuck to Aahz's rule of thumb, without understanding this details,
and still do that.
Skip Montanaro wrote:
aahz> Here's the stark simple recipe: when you use Unicode, you *MUST*
aahz> switch to a Unicode-centric view of the universe. Therefore you
aahz> encode *FROM* Unicode and you decode *TO* Unicode. Period. It's
aahz> similar to the way floating point contami
Max M <[EMAIL PROTECTED]> writes:
> Thomas Heller wrote:
>
>> It seems also the error messages aren't too helpful:
>>
>"ä".encode("latin-1")
>> Traceback (most recent call last):
>> File "", line 1, in ?
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 0:
>> ordinal n
Thomas Heller wrote:
It seems also the error messages aren't too helpful:
"ä".encode("latin-1")
Traceback (most recent call last):
File "", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0x84 in position 0: ordinal
not in range(128)
Hm, why does the 'encode' call complain about
On Tue, 04 Jan 2005 16:41:05 +0100, Thomas Heller <[EMAIL PROTECTED]> wrote:
>Skip Montanaro <[EMAIL PROTECTED]> writes:
>
> > michele> BTW what's the difference between .encode and .decode ?
> >
> > I started to answer, then got confused when I read the docstrings for
> > unicode.encode and u
[EMAIL PROTECTED] wrote:
uhm ... then there is a misprint in the discussion of the recipe;
BTW what's the difference between .encode and .decode ?
(yes, I have been living in happy ASCII-land until now ... ;)
# -*- coding: latin-1 -*-
# here i make a unicode string
unicode_file = u'Some danish cha
Skip Montanaro <[EMAIL PROTECTED]> writes:
> michele> BTW what's the difference between .encode and .decode ?
>
> I started to answer, then got confused when I read the docstrings for
> unicode.encode and unicode.decode:
>
> >>> help(u"\xe4".decode)
> Help on built-in function decode:
Stephan:
> I'd rather use german_ae.encode('latin1')
^^
> which returns '\xe4'.
uhm ... then there is a misprint in the discussion of the recipe;
BTW what's the difference between .encode and .decode ?
(yes, I have been living in happy ASCII-land until now ... ;)
I should probably ask for an
Yep, I did the same and got confused :-/
Michele
--
http://mail.python.org/mailman/listinfo/python-list
aahz> Here's the stark simple recipe: when you use Unicode, you *MUST*
aahz> switch to a Unicode-centric view of the universe. Therefore you
aahz> encode *FROM* Unicode and you decode *TO* Unicode. Period. It's
aahz> similar to the way floating point contaminates ints.
That's wh
In article <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> wrote:
>
>BTW what's the difference between .encode and .decode ?
>(yes, I have been living in happy ASCII-land until now ... ;)
Here's the stark simple recipe: when you use Unicode, you *MUST* switch
to a Unicode-centric view of the universe.
michele> BTW what's the difference between .encode and .decode ?
I started to answer, then got confused when I read the docstrings for
unicode.encode and unicode.decode:
>>> help(u"\xe4".decode)
Help on built-in function decode:
decode(...)
S.decode([encoding[,errors]])
On Tue, 04 Jan 2005 05:43:32 -0800, michele.simionato wrote:
> Holger:
>
>> FWIW, i added the recipe back to the online cookbook. It's not
> perfectly
>> formatted but still useful, i hope.
>
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361742
>
> Uhm... on my system I get:
>
>
Holger:
> FWIW, i added the recipe back to the online cookbook. It's not
perfectly
> formatted but still useful, i hope.
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361742
Uhm... on my system I get:
>>> german_ae = unicode('\xc3\xa4', 'utf8')
>>> print german_ae # dunno if it wi
On Fri, Dec 31, 2004 at 19:18 +0100, Alex Martelli wrote:
> Cameron Laird <[EMAIL PROTECTED]> wrote:
>...
> > Yippee! The martellibot promises to explain Unicode for Pythoneers.
> > http://groups-beta.google.com/group/comp.lang.python/msg/6015a5a05c206712
>
> Uh -- _did_ I? Eeep... I guess
Cameron Laird <[EMAIL PROTECTED]> wrote:
...
> Yippee! The martellibot promises to explain Unicode for Pythoneers.
> http://groups-beta.google.com/group/comp.lang.python/msg/6015a5a05c206712
Uh -- _did_ I? Eeep... I guess I did... mostly, I was pointing to
Holger Krekel's very nice recipe (
QOTW: "I found the discussion of unicode, in any python book I have,
insufficient." -- Thomas Heller
"If you develop on a Mac, ... Objective-C could come in handy. . . .
PyObjC makes mixing the two languages dead easy and more convenient than
indoor plumbing." -- Robert Kern
Among other ac
QOTW: "I found the discussion of unicode, in any python book I have,
insufficient." -- Thomas Heller
"If you develop on a Mac, ... Objective-C could come in handy. . . .
PyObjC makes mixing the two languages dead easy and more convenient than
indoor plumbing." -- Robert Kern
Among other ac
19 matches
Mail list logo