00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <qstring.h>
00011 #include <string.h>
00012
00013 static int mapUTF8 ( Unicode u, char *buf, int bufSize )
00014 {
00015 QCString utf = QString ( QChar ( u )). utf8 ( );
00016 int len = utf. length ( );
00017
00018 if ( len <= bufSize ) {
00019 ::memcpy ( buf, utf. data ( ), len );
00020 return len;
00021 }
00022 else
00023 return 0;
00024 }
00025
00026 static int mapUCS2 ( Unicode u, char *buf, int bufSize)
00027 {
00028 if (u <= 0xffff) {
00029 if (bufSize < 2)
00030 return 0;
00031
00032 buf[0] = (char)((u >> 8) & 0xff);
00033 buf[1] = (char)(u & 0xff);
00034 return 2;
00035 }
00036 else
00037 return 0;
00038 }