It is a pain of ass that Palm does not support Unicode, definitely a big design flaw. It is also a pity that CJKOS would not support the Unicode either, we lost the last chance to patch the system by third party hack. I have to use the GBK encoding in Palm before the legendary PalmOS Garnet or Access Linux Platform available. Unfortunately, the KPilot fails to synchronize the name of the contacts from the KAddressbook, for example, 钟章环 becomes 章&, ^. It is quite curious that part of the string is encoded correctly. Later, I dig into the code, and found this code snippet:

if (!text.isEmpty())
        {
                fAddressInfo.entry[field] = (char *) malloc(text.length() + 1);
                strlcpy(fAddressInfo.entry[field], codec()->fromUnicode(text), text.length() + 1);
        }

The bug results in that the length of the UTF8 encoded string is not the same as the GBK encoded string. A workaround is like this:

if (!text.isEmpty())
        {
                QCString locale = codec()->fromUnicode(text);
                fAddressInfo.entry[field] = (char *) malloc(locale.length() + 1);
                strlcpy(fAddressInfo.entry[field], locale, locale.length() + 1);
        }

It has been submitted to the KDE Bugzilla, Bug 138108.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

One Comment to “Diagnosis of KPilot/Palm’s messy text”

  1. Refactor the Life » Blog Archive » Make it work | June 27th, 2007 at 2:14 pm

    [...] developers have released 3.5.6, and claimed that it has solved lots of long-lasting bug, including my patch as well. However, the KPilot 3.5.6 depends on >=pilot-link-12.0, while pilot-link is buggy for the [...]

Leave a Comment