[C,GTK2,GLib2] UTF-8 string comparision

From: Danijel Schiavuzzi (dschiavuBRISI_at_globalnet.hr)
Date: 08/26/03


Date: Tue, 26 Aug 2003 23:43:22 +0200

Hi.

I'm writing my first app with Glade2/GTK2/GLib in C.

I have a GtkListStore with 2 columns (like a dictionary, word and then
translation) which I fill in with strings read with fscanf from a
intentionally UTF-8 recoded file (it used to be win cp 1250, but UTF-8
is nicer, and Pango doesn't work with other charsets). Displaying it
in a GtkTreeView works nicely also.

1) I have these declared:

   gchar* word1;
   gchar* word2;
   gchar* translation;

2) I fill word with the contents of a GtkEntry:

   word1 = gtk_entry_get_text(entry); /* word to be searched */

3) The other word which is to be compared with the first I get with

   gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter,
                      WORD_COLUMN, &word2,
                      TRANSLATION_COLUMN, &translation,
                      -1);

   This runs in a loop comparing every row from the ListStore with the
   word the user has written into the entry widget (word1):

4) Now I need to compare these two strings, UTF-8 encoded, word1 and
   word2. I tried with strcmp() but it doesn't work. I searched for
   a alternative function in the GLib 2 library but have found nothing
   useful.

Any suggestions would be greatly appreciated!

Sorry for my possible bad English and bad explanations ;-)

-- 
#define QUESTION ((bb) || !(bb))


Relevant Pages

  • Re: edict lookup methods, and a list of problematic RPG-item names
    ... eventual goal is to go through the entire series, comparing the ... official translation to the original to see how it looks; ... if there are any differences if nothing else (aside from small quirks ... I'm workiing purely with the original SNES game. ...
    (sci.lang.japan)
  • Re: EDUx.pt - Novo projecto (www.eduxpt.org)
    ... Thanks, but I was looking for a real translation, one I can safely ... when comparing against Anthony's translation (which I saw only ... after posting the link - thanks Anthony:-) it does a pretty good job in ...
    (Ubuntu)