(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 chuck 1.6 #include <Pegasus/Common/Linkage.h>
 35 chuck 1.7 #include <Pegasus/Common/String.h>
 36 david 1.1 
 37 chuck 1.2 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
 38           
 39 david 1.1 PEGASUS_NAMESPACE_BEGIN
 40           
 41           #define FIRST_HIGH_SURROGATE  (Uint32)0xD800
 42           #define LAST_HIGH_SURROGATE   (Uint32)0xDBFF
 43           #define FIRST_LOW_SURROGATE   (Uint32)0xDC00
 44           #define LAST_LOW_SURROGATE    (Uint32)0xDFFF
 45           #define REPLACEMENT_CHARACTER (Uint32)0x0000FFFD
 46           #define MAX_BYTE              (Uint32)0x0000FFFF
 47           #define MAX_UTF16             (Uint32)0x0010FFFF
 48           
 49           static const Uint32 halfBase = 0x0010000UL;
 50           static const Uint32 halfMask = 0x3FFUL;
 51           static const int halfShift  = 10;
 52           static const Uint8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
 53           
 54           static const Uint32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 
 55           		     0x03C82080UL, 0xFA082080UL, 0x82082080UL };
 56           
 57           static const char trailingBytesForUTF8[256] = {
 58               0,0,0,0,0,0,0,0,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 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,
 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               0,0,0,0,0,0,0,0,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               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,
 65               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
 66           };
 67           
 68           #define UTF_8_COUNT_TRAIL_BYTES(leadByte) (trailingBytesForUTF8[(Uint8)leadByte])
 69           
 70 chuck 1.4 #define UTF8_NEXT(s, i) { \
 71               (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \
 72           } 
 73 david 1.1 
 74           
 75 chuck 1.6 PEGASUS_COMMON_LINKAGE int isValid_U8(const Uint8 *src,int size);
 76           PEGASUS_COMMON_LINKAGE int UTF16toUTF8(const Uint16** srcHead,
 77 david 1.1 		const Uint16* srcEnd, 
 78           		Uint8** tgtHead,
 79           		Uint8* tgtEnd);
 80           
 81 chuck 1.6 PEGASUS_COMMON_LINKAGE int UTF8toUTF16 (const Uint8** srcHead,
 82 david 1.1 		 const Uint8* srcEnd, 
 83           		 Uint16** tgtHead,
 84           		 Uint16* tgtEnd);
 85           
 86 chuck 1.6 PEGASUS_COMMON_LINKAGE Boolean isUTF8(const char*);
 87 chuck 1.7 
 88           /** Escape all characters above 7-bit ASCII.
 89               @param String: The string to be escaped Insert text here.
 90               @return String: The escaped string.
 91           */
 92           PEGASUS_COMMON_LINKAGE String escapeStringEncoder(const String& Str);
 93           
 94           /** decode string returned from escapeString Encoder.
 95               @param String: The string to be decoded.
 96               @return String: The decoded string.
 97           
 98               Prereq: Only the return string from the escapeStringEncoder can be used 
 99                       as input.
100           */
101           PEGASUS_COMMON_LINKAGE String escapeStringDecoder(const String& Str);
102           
103 david 1.5 
104 david 1.1 PEGASUS_NAMESPACE_END
105 chuck 1.2 
106           #endif  // PEGASUS_USE_EXPERIMENTAL_INTERFACES
107           
108 david 1.1 #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2