[TxMt] New "Unicode" bundle in the Review trunk

Walter Dörwald walter at livinglogic.de
Tue Jun 3 20:44:52 UTC 2008


Hans-Jörg Bibiko wrote:
> 
> On 03.06.2008, at 17:29, Walter Dörwald wrote:
> 
>> Walter Dörwald wrote:
>>> Walter Dörwald wrote:
>>>> Hans-Jörg Bibiko wrote:
>>>>
>>>>> On 02.06.2008, at 00:04, Walter Dörwald wrote:
>>>>>> Here's another patch (against the current version). It shows both 
>>>>>> the codepoint and the name.
>>>>>> [...]
>>> Here's another suggestions on the current Bundle version:
>>> To get the UTF-8 bytes of a character, you're doing the following:
>>>     print "  UTF-8         : " + " 
>>> ".join(repr(char.encode("UTF-8")).split('\\x')).lstrip("' 
>>> ").rstrip("'").upper()
>>> This only works for characters with a codepoint >= 128. The following 
>>> code should work better:
>>>     print "  UTF-8         : %s" % " ".join(hex(ord(c))[2:].upper() 
>>> for c in char)
>>
>> Oops, that was of course supposed to be:
>>
>>      print "  UTF-8         : %s" % " ".join(hex(ord(c))[2:].upper() 
>> for  c in char.encode("utf-8"))
> Could it be that this isn't allowed in Python for Tiger? I get an error 
> for invalid syntax referring to 'for'
> Mac OSX 10.4.11 ppc; Python 2.4.2
> 
> On my 10.5.3 Mac it works(?)

AFAICR Tiger has Python 2.3, which didn't support generator expressions.

The following should work:

print "  UTF-8         : %s" % " ".join([hex(ord(c))[2:].upper() for c 
in char.encode("utf-8")])

(i.e. replace the generator expression with a list comprehension by 
adding [] around the join argument.)

Hope that helps!

Servus,
    Walter



More information about the textmate mailing list