(file) Return to CommonUTF.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

 1 karl  1.3 //%2003////////////////////////////////////////////////////////////////////////
 2 david 1.1 //
 3 karl  1.3 // 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           // IBM Corp.; EMC Corporation, The Open Group.
 7 david 1.1 //
 8           // Permission is hereby granted, free of charge, to any person obtaining a copy
 9           // of this software and associated documentation files (the "Software"), to
10           // deal in the Software without restriction, including without limitation the
11           // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12           // sell copies of the Software, and to permit persons to whom the Software is
13           // furnished to do so, subject to the following conditions:
14           // 
15           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16           // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17           // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18           // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19           // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20           // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23           //
24           //==============================================================================
25           //
26           // Author: Dave Rosckes   (rosckes@us.ibm.com)
27           //
28 david 1.1 //
29           //%/////////////////////////////////////////////////////////////////////////////
30           
31           #ifndef Pegasus_CommonUTF_h
32           #define Pegasus_CommonUTF_h
33           #include <Pegasus/Common/Config.h>
34           
35 chuck 1.2 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
36           
37 david 1.1 PEGASUS_NAMESPACE_BEGIN
38           
39           #define FIRST_HIGH_SURROGATE  (Uint32)0xD800
40           #define LAST_HIGH_SURROGATE   (Uint32)0xDBFF
41           #define FIRST_LOW_SURROGATE   (Uint32)0xDC00
42           #define LAST_LOW_SURROGATE    (Uint32)0xDFFF
43           #define REPLACEMENT_CHARACTER (Uint32)0x0000FFFD
44           #define MAX_BYTE              (Uint32)0x0000FFFF
45           #define MAX_UTF16             (Uint32)0x0010FFFF
46           
47           static const Uint32 halfBase = 0x0010000UL;
48           static const Uint32 halfMask = 0x3FFUL;
49           static const int halfShift  = 10;
50           static const Uint8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
51           
52           static const Uint32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 
53           		     0x03C82080UL, 0xFA082080UL, 0x82082080UL };
54           
55           static const char trailingBytesForUTF8[256] = {
56               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,
57               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,
58 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,
59               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,
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               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,
63               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
64           };
65           
66           #define UTF_8_COUNT_TRAIL_BYTES(leadByte) (trailingBytesForUTF8[(Uint8)leadByte])
67           
68 chuck 1.4 #define UTF8_NEXT(s, i) { \
69               (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \
70           } 
71 david 1.1 
72           
73           int isValid_U8(const Uint8 *src,int size);
74           int UTF16toUTF8(const Uint16** srcHead,
75           		const Uint16* srcEnd, 
76           		Uint8** tgtHead,
77           		Uint8* tgtEnd);
78           
79           int UTF8toUTF16 (const Uint8** srcHead,
80           		 const Uint8* srcEnd, 
81           		 Uint16** tgtHead,
82           		 Uint16* tgtEnd);
83           
84           PEGASUS_NAMESPACE_END
85 chuck 1.2 
86           #endif  // PEGASUS_USE_EXPERIMENTAL_INTERFACES
87           
88 david 1.1 #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2