>Is there a
> >system API for it (sorry, but I could not find it)? If not, is there
> >any code snippet for it?
>
> First, a general comment that most routines for direct text
> manipulation are either in the String Mgr or the Text Mgr, so that's
> where you'd want to start looking.
True. My fault. I was diverted from the fact that the web search
utility did not give me any meaningful link with different keywords
(such as utf8)...
>
> Second, a comment on the code Greg posted...you'll need to use
> LmGlueGetSystemLocale(), since LmGetSystemLocale was added in 6.0.
Likely I do not need to support prior OS4.1 devices.
>
> Finally, there are two other reasons for the existence of
> TxtGlueConvertEncoding beyond backwards compatibility to 3.5. It also
Shouldn't I have to use FtrGet(sysFtrCreator, sysFtrNumEncoding, &encoding);
instead?
I am going to use the following code:
char* wc2utf8(wchar_t* s, char* d = NULL, unsigned long dsize = 0) {
//
// First of all, if s is NULL, just return NULL.
// Then, if d is NULL, let's allocate the required memory to contain the
// utf8 string.
//
if (s == NULL) {
return NULL;
}
if (d == NULL) {
dsize = utf8len(s);
d = new char[dsize+1];
}
//
// Let's convert!
//
Err err = errNone;
UInt16 lenSrc = wcslen(s);
UInt16 lenDst = (UInt16)dsize;
UInt32 encoding;
FtrGet(sysFtrCreator, sysFtrNumEncoding, &encoding);
err = TxtConvertEncoding(
true,
NULL,
(Char*)s,
&lenSrc,
(CharEncodingType)encoding,
d,
&lenDst,
charEncodingUTF8,
"?",
1
);
return (err == errNone) ? d : NULL;
}
Stefano
--
Stefano Fornari - Sync4j Project Manager / Funambol CTO
=======================================================
Home:
http://www.sync4j.org
FAQ:
http://sync4j.funambol.com/main.jsp?main=faq
Project Documentation:
http://forge.objectweb.org/docman/index.php?group_id=96
Documentation site:
http://sync4j.funambol.com/main.jsp?main=documentation
List archives:
http://groups.yahoo.com/group/Sync4j (login required)
http://sourceforge.net/mailarchive/forum.php?forum_id=215
Wiki:
http://wiki.objectweb.org/sync4j/
Sync4j - The open source SyncML mobile application platform
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/