Bug 138108 - Messy text with UTF-8(desktop) and GBK(Palm)
Summary: Messy text with UTF-8(desktop) and GBK(Palm)
Status: RESOLVED FIXED
Alias: None
Product: kpilot
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: groot
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-29 22:24 UTC by Kun Xi
Modified: 2009-01-19 06:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kun Xi 2006-11-29 22:24:50 UTC
Version:           4.6.0 (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages
Compiler:          gcc-4.1.1 
OS:                Linux

Desktop: Gentoo Linux, KDE 3.5.5, everything is built via ebuild, GCC 4.1.1
Handheld: Palm Tungsten T

The problem exists in the KAddressbook sync with Palm's Contacts. In Palm, the Chinese character is encoded in GBK, while the Linux box take the en_US.UTF8 as the locale. After the synchronization, the Palm's contact is synced with messed text. 

I dig into the problem, and find the bug in pilotAddress.cc, Here is the patch for kdepim-3.5.4 package, this bug also resides in the svn HEADER:


diff -ur kdepim-3.5.4.orig/kpilot/lib/pilotAddress.cc kdepim-3.5.4/kpilot/lib/pilotAddress.cc
--- kdepim-3.5.4.orig/kpilot/lib/pilotAddress.cc	2006-11-21 16:01:54.486213888 -0500
+++ kdepim-3.5.4/kpilot/lib/pilotAddress.cc	2006-11-21 16:03:10.937591512 -0500
@@ -692,8 +692,9 @@
 	}
 	if (!text.isEmpty())
 	{
-		fAddressInfo.entry[field] = (char *) malloc(text.length() + 1);
-		strlcpy(fAddressInfo.entry[field], codec()->fromUnicode(text), text.length() + 1);
+		QCString locale = codec()->fromUnicode(text);
+		fAddressInfo.entry[field] = (char *) malloc(locale.length() + 1);
+		strlcpy(fAddressInfo.entry[field], locale, locale.length() + 1);
 	}
 	else
 	{


The problem here is the length of gbk string is not equal utf8 string.
Comment 1 groot 2006-11-30 11:59:16 UTC
On Wednesday 29 November 2006 22:24, Kun Xi wrote:
> The problem exists in the KAddressbook sync with Palm's Contacts. In Palm,
> the Chinese character is encoded in GBK, while the Linux box take the
> en_US.UTF8 as the locale. After the synchronization, the Palm's contact is
> synced with messed text.


Thank you for the patch. I have applied something similar to KPilot's SVN, and 
that will be merged to KPilot in KDE SVN for KDE 3.5.6.
Comment 2 Jason 'vanRijn' Kasper 2009-01-19 06:03:14 UTC
Excellent news. A fixed bug! =:)

Thank you for the bug report!! Also, I'd really appreciate your help in testing out KPilot from the really-soon-to-be-released KDE 4.2!!! =:)