How work g_locale_to_utf8_() on pb (GTK) ?

Linux specific forum
Anonymous

How work g_locale_to_utf8_() on pb (GTK) ?

Post 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
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post 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)

Anonymous

Post 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
Post Reply