/****** UTF8 ******/ #define b10000000 (guchar)(0x80) #define b11000000 (guchar)(0xC0) #define b11100000 (guchar)(0xE0) #define b11110000 (guchar)(0xF0) #define b00111111 (guchar)(0x3F) #define b00011111 (guchar)(0x1F) #define b00001111 (guchar)(0x0F) #define b00000111 (guchar)(0x07) static inline guchar *utf8_char( guint32 uCode, guchar *pcOut ) { g_assert( pcOut!=NULL ); if( uCode<128 ) { pcOut[0] = (guchar) uCode ; pcOut[1] = '\0' ; return( pcOut ); } if( uCode<4096 ) { pcOut[0] = b11000000 | ( (guchar)(uCode >> 6) & b00011111 ); pcOut[1] = b10000000 | ( (guchar)(uCode ) & b00111111 ); pcOut[2] = '\0' ; return( pcOut ); } if( uCode<65535 ) { pcOut[0] = b11100000 | ( (guchar)(uCode >> 12) & b00001111 ); pcOut[1] = b10000000 | ( (guchar)(uCode >> 6 ) & b00111111 ); pcOut[2] = b10000000 | ( (guchar)(uCode ) & b00111111 ); pcOut[3] = '\0' ; return( pcOut ); } pcOut[0] = '\0' ; return(NULL); }