Jython: Upper-ASCII characters '\351' from chr(233)

Maurice Bauhahn bauhahnm at clara.net
Fri Apr 20 16:45:33 EDT 2001


Thank you for the suggestion, D-Man.

However, I doubt that this is a problem with the display, because I can see all
these unusual characters when I print a line of text to the screen. The problem
becomes obvious when I try one of those upper ASCII characters as a key of the
dictionary...it does not work. My hope is to compare each character from a text
file...and use the dictionary to assist in translation of those characters to
Unicode (the Cambodian script...so standard Java code converters are not useful).

Maybe I will have to call a Java function to accomplish my desired task, right?

Cheers,

Maurice

D-Man wrote:

> 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