Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UTF8.h

Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // UTF8.h
00004 //
00005 // Copyright 2001 Derek B. Noonburg
00006 // Modified for QPE by Robert Griebl
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 }

Generated on Sat Nov 5 16:18:12 2005 for OPIE by  doxygen 1.4.2