Jython: Upper-ASCII characters '\351' from chr(233)
D-Man
dsh8290 at rit.edu
Fri Apr 20 15:52:17 EDT 2001
On Fri, Apr 20, 2001 at 08:32:23PM +0100, Maurice Bauhahn wrote:
| I'm trying to create a dictionary in jython where the key is an
| individual character (one byte). Because of the difficulty of entering
| each such character (especially the upper-ASCII ones or eventually
| Unicode ones), it seems appropriate to have Jython convert a decimal or
| hexadecimal number to a character. However whenever the chr() function
| encounters a number above 127 the result is as follows:
| >>> chr(127)
| '?' (in fact a character like a house)
| >>>chr(233)
| '\351'
| Any suggestions on how to get around this?
I think that is a result of your terminal/display.
>>> chr( 127 )
'¦' # heh, nice cut-n-paste, it looks more like the "delta" symbol (triangle)
>>> chr( 233 )
'\351'
>>> ord( chr( 233 ) )
233
>>> oct( ord( chr( 233 ) ) )
'0351'
I don't think it is a problem with the functionality.
-D
More information about the Python-list
mailing list