Prev: py2exe sets error message
Next: Detect OS shutdown or user logout across different operatingsystems
From: Dodo on 26 Apr 2010 16:12 Hi all, Under python 2.6, chr() "Return a string of one character whose ASCII code is the integer i." (quoted from docs.python.org) Under python 3.1, chr() "Return the string of one character whose Unicode codepoint is the integer i." I want to convert a ASCII code back to a character under python 3, not Unicode. How can I do that? Dorian
From: Alf P. Steinbach on 26 Apr 2010 16:26 On 26.04.2010 22:12, * Dodo: > Hi all, > Under python 2.6, chr() "Return a string of one character whose ASCII > code is the integer i." (quoted from docs.python.org) > Under python 3.1, chr() "Return the string of one character whose > Unicode codepoint is the integer i." > > I want to convert a ASCII code back to a character under python 3, not > Unicode. > > How can I do that? Just use chr(). ASCII (7-bit) is a subset of ISO Latin-1 (7-bit), which is a subset of Unicode's Basic Multilingual Plane (BMP, original Unicode, 16-bit) which is a subset of Unicode (21-bit). Cheers & hth., - Alf
From: Dodo on 26 Apr 2010 16:26 Le 26/04/2010 22:26, Alf P. Steinbach a �crit : > On 26.04.2010 22:12, * Dodo: >> Hi all, >> Under python 2.6, chr() "Return a string of one character whose ASCII >> code is the integer i." (quoted from docs.python.org) >> Under python 3.1, chr() "Return the string of one character whose >> Unicode codepoint is the integer i." >> >> I want to convert a ASCII code back to a character under python 3, not >> Unicode. >> >> How can I do that? > > Just use chr(). > > ASCII (7-bit) is a subset of ISO Latin-1 (7-bit), which is a subset of > Unicode's Basic Multilingual Plane (BMP, original Unicode, 16-bit) which > is a subset of Unicode (21-bit). > > > Cheers & hth., > > - Alf Oh, I see... thanks * just realize the problem doesn't come from here *
From: Alf P. Steinbach on 26 Apr 2010 18:44 On 26.04.2010 22:26, * Dodo: > Le 26/04/2010 22:26, Alf P. Steinbach a �crit : >> On 26.04.2010 22:12, * Dodo: >>> Hi all, >>> Under python 2.6, chr() "Return a string of one character whose ASCII >>> code is the integer i." (quoted from docs.python.org) >>> Under python 3.1, chr() "Return the string of one character whose >>> Unicode codepoint is the integer i." >>> >>> I want to convert a ASCII code back to a character under python 3, not >>> Unicode. >>> >>> How can I do that? >> >> Just use chr(). >> >> ASCII (7-bit) is a subset of ISO Latin-1 (7-bit), which is a subset of >> Unicode's Basic Multilingual Plane (BMP, original Unicode, 16-bit) which >> is a subset of Unicode (21-bit). >> >> >> Cheers & hth., >> >> - Alf > > Oh, I see... thanks > > * just realize the problem doesn't come from here * Uhm, I meant to write that ISO Latin-1 is 8-bit. Sorry. Keyboard gremlin. Cheers, - Alf
From: Antoine Pitrou on 27 Apr 2010 04:04 Le Mon, 26 Apr 2010 22:26:28 +0200, Alf P. Steinbach a écrit : > On 26.04.2010 22:12, * Dodo: >> Hi all, >> Under python 2.6, chr() "Return a string of one character whose ASCII >> code is the integer i." (quoted from docs.python.org) Under python 3.1, >> chr() "Return the string of one character whose Unicode codepoint is >> the integer i." >> >> I want to convert a ASCII code back to a character under python 3, not >> Unicode. >> >> How can I do that? > > Just use chr(). Or, if you want a bytes object, just use the bytes constructor: >>> bytes([65]) b'A' Regards Antoine.
|
Next
|
Last
Pages: 1 2 Prev: py2exe sets error message Next: Detect OS shutdown or user logout across different operatingsystems |