Hi there,

if I use gettext files in UTF-8 encoding (didn't check anything
other), I get warnings like this:

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/dabo/dabo/ui/uiwx/dMenuItem.py:66:
UnicodeWarning: Unicode unequal comparison failed to convert both
arguments to Unicode - interpreting them as being unequal
  if cap != curr:

and unicode characters like umlauts show up as the two bytes of UTF-8
in the menus - while I didn't define any own menu items.

I patched dMenuItem like this:

    def _forceUnicode(self, text):
        if type(text) is unicode: return text
        if text is None: return '' # something's sometimes None!
        try:
            text = unicode(text, 'utf-8')
        except: # never got into that
            import unicodedata
            text = unicodedata.normalize('NFKD', text).encode('ASCII', 'ignore')
        return text

    def _redefine(self):
        """Combine the Caption and HotKey into the format needed by wxPython."""
        cap = self.Caption
        hk = self.HotKey
        cap = self._forceUnicode(cap)
        hk = self._forceUnicode(hk)
        if hk:
            cap = "%s\t%s" % (cap, hk)
        curr = self.GetText()
        if cap != curr:
            ## Win32 seems to need to clear the caption first, or funkiness
            ## can arise. And win32 in wx2.8 needs for the caption to never be
            ## an empty string, or you'll get an invalid stock id assertion.
            self.SetText(" ")
            if cap == "":
                cap = " "
            self.SetText(cap)

I know it's ugly and probably doesn't fix everything (my About box
should have a caption of "Über" in German, that's still messed up) -
can you guess where the real error sits? Maybe in dPemMixin's Caption
handling?


Platform: Mac (OSX 10.4)
Python Version: 2.5.1 on darwin
Dabo Version: Version 0.8.3; Revision 4102M
UI Version: 2.8.7.1 on wxMac

Greetlings from Lake Constance!
Hraban
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to