Re: Gammu api: encoding unicode sms on Linux (UTF-8)
Cellular manager for mobile phones/modems
Brought to you by:
marcinello,
nijel
From: Michal <mi...@ci...> - 2007-11-14 15:12:29
|
Hi Dne Wed, 14 Nov 2007 13:15:04 +0100 "Tobias Andersson" <tan...@gm...> napsal(a): > I do not understand how to use the EncodeUnicode function in the gammu > API to encode unicode messages (containing swedish letters to be > exact). > I am using the sms-send.c example distributed with gammu as a template > and then adding new code to it. >=20 > Basically I am trying to read a message (a single line of bytes) from > a text-file created locally, put the line it into a char-array > (c-string) and then set the _Text_ member of _GSM_SMSMessage_ to the > message using the EncodeUnicode function like this: >=20 > GSM_SMSMessage sms; > char string_from_textfile[500] =3D ""; > ... > fgets(string_from_textfile, 500, fp); > ... > EncodeUnicode(sms.Text, string_from_textfile, strlen(string_from_textf= ile)); If you are using code based on example in sources, you should also change sms.Coding to allow Unicode message. > The docs about EncodeUnicode says: "encodes string from local charset > to unicode" so sms.Text should now (if I understand this correctly) > contain a unicode representation of the string read from the textfile. > I am running Linux. My locale is sv_SE.UTF-8 with charmap UTF-8; > gammucoding is set to "utf8" in gammurc. For properly working EncodeUnicode you should also initialize locales in your program (just call GSM_InitLocales(NULL) ). --=20 Michal =C4=8Ciha=C5=99 | http://cihar.com | http://blog.cihar.com |