Hello Gianluca,
the function to encode a UTF8 string from XString is actually not available. However, this enhancement is already waiting on our to-do list. For the moment you will need to implement the function by yourself. The following dummy code could help you (based on the description found here):
XChar* src = <EmWi String> unsigned char* dst = <buffer to store the encoded URF8> for ( ; src && *src; src++ ) { XChar c = *src; if ( *src <= 0x007F ) *dst++ = (unsigned char)c; else if ( *src <= 0x07FF ) { *dst++ = (unsigned char)( c >> 6 ) | 0xA0; *dst++ = (unsigned char)( c & 0x3F ) | 0x80; } else if ( *src <= 0xFFFF ) { *dst++ = (unsigned char)( c >> 12 ) | 0xE0; *dst++ = (unsigned char)(( c >> 6 ) & 0x3F ) | 0x80; *dst++ = (unsigned char)( c & 0x3F ) | 0x80; } }
Best regards
Paul Banach
Ask Embedded Wizard - Archive
Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!
Your resources:
The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.
For dedicated assistance, explore our Embedded Wizard Product Support.
You can still browse the valuable discussions from our community history here.
Embedded Wizard Website | Privacy Policy | Imprint