FIX: Garmin charsets - can display cyrillic maps now.
authorzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 10 Oct 2008 09:39:23 +0000 (09:39 +0000)
committerzaxl <zaxl@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 10 Oct 2008 09:39:23 +0000 (09:39 +0000)
Register the driver as utf-8 and do the
conversion depending on the actual charset in the map.
gmapsupp.img is a container that can hold several maps combined
and they can have different encodings. But they are registered
as single map in the core. The correct way to do this is
to allow map drivers to register maps in the core.

git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1444 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/data/garmin/garmin.c

index d6d39d4..c9b0381 100644 (file)
@@ -137,18 +137,32 @@ static int
 garmin_object_label(struct gobject *o, struct attr *attr)
 {
        struct map_rect_priv *mr = o->priv_data;
+       char *codepage;
+       char *label;
        if (!mr) {
                dlog(1, "Error object do not have priv_data!!\n");
                return 0;
        }
-       if (mr->label)
+       if (mr->label) {
                free(mr->label);
-       mr->label = gar_get_object_lbl(o);
-#warning FIXME Process label and give only the visible part
+       }
+       label = gar_get_object_lbl(o);
+       if (label) {
+               codepage = gar_obj_codepage(o);
+               if (*codepage != 'a') {
+                       mr->label = g_convert(label, -1,"utf-8",codepage,NULL,NULL,NULL);
+                       free(label);
+               } else
+                       mr->label = label;
+       } else {
+               mr->label = NULL;
+               return 0;
+       }
        if (mr->label) {
                char *cp = mr->label;
+#warning FIXME Process label and give only the visible part
                if (*mr->label == '@' || *mr->label == '^')
-                       cp++;
+                       cp++; 
                /* FIXME: If zoomlevel is high convert ^ in the string to spaces */
                attr->u.str = cp;
                return 1;
@@ -714,9 +728,8 @@ gmap_destroy(struct map_priv *m)
 
 static struct map_methods map_methods = {
        projection_garmin,
-//     NULL,   FIXME navit no longer displays labels without charset!
-       "iso8859-1",    // update from the map
-       gmap_destroy,   //
+       "utf-8",
+       gmap_destroy,
        gmap_rect_new,
        gmap_rect_destroy,
        gmap_rect_get_item,