bookmark conversion problem
KUSANO Takayuki <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
When Galeon HEAD starts up and detect an old bookmark file saved by
Galeon 1, it can convert it to new format file (if user desired).
I try to convert Galeon 1 bookmark file (XBEL format) by this feature,
but all entries in bookmark become corrupted.
I modifed gb_bookmark_set_fix_galeon1_mess_string() in
bookmarks/bookmarks.c to address this problem.
When Galeon 1 save bookmark items to file, it passes UTF-8 encoded
string to libxml1 APIs. libxml1 treats UTF-8 encoded strings as if
they are encoded in ISO Latin-1, and split string every bytes and
convert them to numerical entity references.
So, we can convert Galeon 1 bookmark to correct UTF-8 encoded file
by perl like this.
perl -pe 's/&#(\d+);/pack("C",$1)/ge' < bookmarks.xbel > new-bookmarks.xbel
I tested attached patch by my bookmark file which contains Japanese
strings, but I'm not sure this is the right way to do.
Regards,
KUSANO Takayuki <URL:http://www.asahi-net.or.jp/~AE5T-KSN/>
--- galeon.orig/bookmarks/bookmarks.c 2002-10-18 02:40:15.000000000 +0900
+++ galeon/bookmarks/bookmarks.c 2002-10-24 02:23:19.000000000 +0900
@@ -2754,21 +2754,10 @@
static char *
gb_bookmark_set_fix_galeon1_mess_string (const gchar *s)
{
- char *sl = g_locale_from_utf8 (s, -1, NULL, NULL, NULL);
- if (sl)
+ char *si = g_convert(s, -1, "ISO-8859-1", "UTF-8", NULL, NULL, NULL);
+ if (si)
{
- /* check if the result is valid */
- char *sll = g_locale_from_utf8 (sl, -1, NULL, NULL, NULL);
- if (sll)
- {
- g_free (sll);
- return sl;
- }
- else
- {
- g_free (sl);
- return g_strdup (s);
- }
+ return si;
}
else
{