Page 1 of 1

How work g_locale_to_utf8_() on pb (GTK) ?

Posted: Wed Aug 08, 2007 5:20 pm
by Anonymous
i have made an single menu with gtk, i use this char ( é à î ô , etc... )
i wan't convert this in utf8 with g_locale_to_utf8_() function :

Code: Select all

Utf8 = g_locale_to_utf8_("French is hard : é è à ...",-1,#null,#null,#null)
and

Code: Select all

 pLabel=gtk_label_new(sUtf8)
doesn't work because gtk_label_new() need a string as params , and g_locale...() return int...
and with peeks() doesn't work too...

Thx for any help. :P

Posted: Thu Aug 09, 2007 7:52 am
by Progi1984
Try this code

Code: Select all

Macro RMisc_GTK_AsciiToUTF8(Text)
  Len = MemoryStringLength(@  , #PB_UTF8)
  *Mem = AllocateMemory(Len + 2)
  PokeS(*mem, Text, -1, #PB_UTF8)
EndMacro

RMisc_GTK_AsciiToUTF8("French is hard : é è à ...")
 pLabel=gtk_label_new(*Mem)
FreeMemory(*mem)


Posted: Thu Aug 09, 2007 12:34 pm
by Anonymous
Exelent ! thanks :D

i translate your macro in procedure :

Code: Select all

Procedure.s RMisc_GTK_AsciiToUTF8(Text.s)
  Len = MemoryStringLength(@Text , #PB_UTF8)
  *Mem = AllocateMemory(Len + 2)
  PokeS(*mem, Text, -1, #PB_UTF8)
ProcedureReturn PeekS(*Mem)
EndProcedure
Thx very much the north man of the south ! :D