![]() ![]() |
![]() |
1 karl 1.8 //%2004//////////////////////////////////////////////////////////////////////// | ||
2 david 1.1 // | ||
3 karl 1.8 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development 4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. 5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; | ||
6 karl 1.3 // IBM Corp.; EMC Corporation, The Open Group. | ||
7 karl 1.8 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; 8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | ||
9 david 1.1 // 10 // Permission is hereby granted, free of charge, to any person obtaining a copy 11 // of this software and associated documentation files (the "Software"), to 12 // deal in the Software without restriction, including without limitation the 13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 14 // sell copies of the Software, and to permit persons to whom the Software is 15 // furnished to do so, subject to the following conditions: 16 // 17 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN 18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED 19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 // 26 //============================================================================== 27 // 28 // Author: Dave Rosckes (rosckes@us.ibm.com) 29 // 30 david 1.1 // 31 //%///////////////////////////////////////////////////////////////////////////// 32 33 #ifndef Pegasus_CommonUTF_h 34 #define Pegasus_CommonUTF_h 35 #include <Pegasus/Common/Config.h> | ||
36 chuck 1.6 #include <Pegasus/Common/Linkage.h> | ||
37 chuck 1.7 #include <Pegasus/Common/String.h> | ||
38 david 1.1 | ||
39 chuck 1.2 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES 40 | ||
41 david 1.1 PEGASUS_NAMESPACE_BEGIN 42 43 #define FIRST_HIGH_SURROGATE (Uint32)0xD800 44 #define LAST_HIGH_SURROGATE (Uint32)0xDBFF 45 #define FIRST_LOW_SURROGATE (Uint32)0xDC00 46 #define LAST_LOW_SURROGATE (Uint32)0xDFFF 47 #define REPLACEMENT_CHARACTER (Uint32)0x0000FFFD 48 #define MAX_BYTE (Uint32)0x0000FFFF 49 #define MAX_UTF16 (Uint32)0x0010FFFF 50 51 static const Uint32 halfBase = 0x0010000UL; 52 static const Uint32 halfMask = 0x3FFUL; 53 static const int halfShift = 10; 54 static const Uint8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; 55 56 static const Uint32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 57 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; 58 59 static const char trailingBytesForUTF8[256] = { 60 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, 61 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, 62 david 1.1 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, 63 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, 64 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, 65 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, 66 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, 67 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 68 }; 69 70 #define UTF_8_COUNT_TRAIL_BYTES(leadByte) (trailingBytesForUTF8[(Uint8)leadByte]) 71 | ||
72 chuck 1.4 #define UTF8_NEXT(s, i) { \ 73 (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \ 74 } | ||
75 david 1.1 76 | ||
77 chuck 1.6 PEGASUS_COMMON_LINKAGE int isValid_U8(const Uint8 *src,int size); 78 PEGASUS_COMMON_LINKAGE int UTF16toUTF8(const Uint16** srcHead, | ||
79 david 1.1 const Uint16* srcEnd, 80 Uint8** tgtHead, 81 Uint8* tgtEnd); 82 | ||
83 chuck 1.6 PEGASUS_COMMON_LINKAGE int UTF8toUTF16 (const Uint8** srcHead, | ||
84 david 1.1 const Uint8* srcEnd, 85 Uint16** tgtHead, 86 Uint16* tgtEnd); 87 | ||
88 chuck 1.6 PEGASUS_COMMON_LINKAGE Boolean isUTF8(const char*); | ||
89 chuck 1.7 90 /** Escape all characters above 7-bit ASCII. 91 @param String: The string to be escaped Insert text here. 92 @return String: The escaped string. 93 */ 94 PEGASUS_COMMON_LINKAGE String escapeStringEncoder(const String& Str); 95 96 /** decode string returned from escapeString Encoder. 97 @param String: The string to be decoded. 98 @return String: The decoded string. 99 100 Prereq: Only the return string from the escapeStringEncoder can be used 101 as input. 102 */ 103 PEGASUS_COMMON_LINKAGE String escapeStringDecoder(const String& Str); 104 | ||
105 david 1.5 | ||
106 david 1.1 PEGASUS_NAMESPACE_END | ||
107 chuck 1.2 108 #endif // PEGASUS_USE_EXPERIMENTAL_INTERFACES 109 | ||
110 david 1.1 #endif |
No CVS admin address has been configured |
Powered by ViewCVS 0.9.2 |