On Monday 05 July 2010 13:53:22 Jörgen Scheibengruber wrote:
> In the Maemo5 version of eds e_contact_new_from_vcard() internally uses
> a heuristic (the same as gecko uses) to figure out the charset (if the
> passed string is not utf-8). If you know the charset, then of course
> it's best to g_convert() the string obtained from g_file_get_contents()
> into utf-8 first, then there is no need for guessing...

Ah, thanks for that (it would be useful if the documentation said that -- at a 
minimum it should say it prefers UTF-8).

So, if e_contact_new_from_vcard has a decent heuristic, it probably is as easy 
as your examp[le showed.  And it has the advantage that any bug reports 
complaining about charset issues can be forwarded straight to the EDS team!

> version 2.1 vcards actually allow to specify the encoding inline in the
> vcard, but for 3.0 this was dropped. Which was maybe not the most clever
> decision ever. Then again, everybody really should just use utf-8 :-P

I was never too fond of the V2.1 charset mechanism (I always felt the whole 
file should be in a single charset) but 3.0 definitely should have left a 
mechanism for the card to document its own charset!

Judging from the collection of files people have sent to me (as gpe-calendar 
and gpe-contacts maintainer for Maemo) we are a long way off everyone using 
UTF-8!

> > I don't recommend using g_file_get_contents to read the file unless you
> > are prepared to write code to handle the charset conversions.
>
> g_convert() ?

You are right, of course.  But I take back the comment anyway as 
e_contact_new_from_vcard does that for us.

Graham
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to