version 1.14.2.1, 2006/02/10 16:09:35
|
version 1.18, 2006/11/07 21:30:36
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Dave Rosckes (rosckes@us.ibm.com) |
|
// |
|
// Modified By: Yi Zhou Hewlett-Packard Company (yi.zhou@hp.com) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#ifndef Pegasus_CommonUTF_h | #ifndef Pegasus_CommonUTF_h |
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/Linkage.h> | #include <Pegasus/Common/Linkage.h> |
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/IPC.h> |
#include <Pegasus/Common/Mutex.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
#define MAX_BYTE (Uint32)0x0000FFFF | #define MAX_BYTE (Uint32)0x0000FFFF |
#define MAX_UTF16 (Uint32)0x0010FFFF | #define MAX_UTF16 (Uint32)0x0010FFFF |
| |
static const Uint32 halfBase = 0x0010000UL; |
PEGASUS_COMMON_LINKAGE extern const Uint32 halfBase; |
static const Uint32 halfMask = 0x3FFUL; |
PEGASUS_COMMON_LINKAGE extern const Uint32 halfMask; |
static const int halfShift = 10; |
PEGASUS_COMMON_LINKAGE extern const int halfShift; |
static const Uint8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; |
PEGASUS_COMMON_LINKAGE extern const Uint8 firstByteMark[]; |
|
|
static const Uint32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, |
|
0x03C82080UL, 0xFA082080UL, 0x82082080UL }; |
|
|
|
static const char trailingBytesForUTF8[256] = { |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 |
|
}; |
|
| |
#define UTF_8_COUNT_TRAIL_BYTES(leadByte) (trailingBytesForUTF8[(Uint8)leadByte]) |
PEGASUS_COMMON_LINKAGE extern const Uint32 offsetsFromUTF8[]; |
|
|
|
PEGASUS_COMMON_LINKAGE extern const char trailingBytesForUTF8[]; |
|
|
|
#define UTF_8_COUNT_TRAIL_BYTES(leadByte) \ |
|
(trailingBytesForUTF8[(Uint8)leadByte]) |
| |
#define UTF8_NEXT(s, i) { \ | #define UTF8_NEXT(s, i) { \ |
(i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \ | (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \ |
} | } |
| |
|
|
PEGASUS_COMMON_LINKAGE Boolean isValid_U8(const Uint8 *src,int size); | PEGASUS_COMMON_LINKAGE Boolean isValid_U8(const Uint8 *src,int size); |
| |
PEGASUS_COMMON_LINKAGE int UTF16toUTF8( | PEGASUS_COMMON_LINKAGE int UTF16toUTF8( |