[Kde-pim] Using kmime lib to create UTF-8 email message

Ingo Klöcker kloecker at kde.org
Wed Jan 20 19:22:42 GMT 2010


On Wednesday 20 January 2010, David Jarvie wrote:
> On Wed, January 20, 2010 12:03 am, David Jarvie wrote:
> > Hi Ingo,
> >
> > On Tuesday 19 Jan 2010 23:24:23 Ingo Klöcker wrote:
> >> On Tuesday 19 January 2010, David Jarvie wrote:
> >> > I attach the whole email text which was returned by
> >> > encodedContent(). The two ways of producing it (setBody() and
> >> > fromUnicodeString()) both produce the same result. The original
> >> > body text was some Cyrillic text conveniently provided by a spam
> >> > email which I was sent):
> >> >
> >> > Під час клацання
> >>
> >> The problem is that this Cyrillic text was converted twice from
> >> Unicode to utf-8, i.e. the result of the first conversion was
> >> again interpreted as Unicode and then recoded to utf-8.
> >
> > I'm not sure how that would have been done, since converting to
> > UTF-8 changes it to a QByteArray, not a QString. Would a double
> > conversion be produced by this? (Note that I'm not aware of this
> > actually having happened):
> >
> >    bodyText = QString(originalBodyText.toUtf8())

No. The QString-c'tor will interpret the byte array as a local-encoded 
string and since the local encoding is mostly UTF-8 nowadays (on Linux 
anyway) this will not produce a double conversion.


> >> Are you sure that bodyText contains the correct Unicode string?
> >> How did you set bodyText? If bodyText does already contain a utf-8
> >> encoded version of the text instead of the Unicode version then
> >> this would explain your observations.
> >
> > I've printed out the bodyText QString using kDebug(), and it shows
> > the correct Cyrillic text on konsole (which has UTF-8 set as the
> > default character encoding). Is this sufficient evidence that it
> > contains the correct Unicode string, or could that be misleading?
>
> I've checked further, and I'm convinced that the QString supplied to
> fromUnicodeString() is the same as is supplied to
> KCal::Alarm::setEmailAlarm() when writing to the calendar. It is
> stored correctly as Cyrillic text in the calendar file.

Hmm, then I'm out of ideas as I don't really know KMime.


Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100120/c4b8678e/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list