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

  1 karl  1.15 //%2006////////////////////////////////////////////////////////////////////////
  2 david 1.1  //
  3 karl  1.10 // 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.10 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9            // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.15 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 david 1.1  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15            // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18            // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 karl  1.15 // 
 21 david 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            // Author: Dave Rosckes   (rosckes@us.ibm.com)
 33            //
 34 yi.zhou 1.12 // Modified By: Yi Zhou Hewlett-Packard Company (yi.zhou@hp.com)
 35 david   1.1  //
 36              //%/////////////////////////////////////////////////////////////////////////////
 37              
 38              #ifndef Pegasus_CommonUTF_h
 39              #define Pegasus_CommonUTF_h
 40              #include <Pegasus/Common/Config.h>
 41 chuck   1.6  #include <Pegasus/Common/Linkage.h>
 42 chuck   1.7  #include <Pegasus/Common/String.h>
 43 mike    1.16 #include <Pegasus/Common/Mutex.h>
 44 david   1.1  
 45              PEGASUS_NAMESPACE_BEGIN
 46              
 47              #define FIRST_HIGH_SURROGATE  (Uint32)0xD800
 48              #define LAST_HIGH_SURROGATE   (Uint32)0xDBFF
 49              #define FIRST_LOW_SURROGATE   (Uint32)0xDC00
 50              #define LAST_LOW_SURROGATE    (Uint32)0xDFFF
 51              #define REPLACEMENT_CHARACTER (Uint32)0x0000FFFD
 52              #define MAX_BYTE              (Uint32)0x0000FFFF
 53              #define MAX_UTF16             (Uint32)0x0010FFFF
 54              
 55 karl    1.17 PEGASUS_COMMON_LINKAGE extern const Uint32 halfBase;
 56              PEGASUS_COMMON_LINKAGE extern  const Uint32 halfMask;
 57              PEGASUS_COMMON_LINKAGE extern  const int halfShift;
 58              PEGASUS_COMMON_LINKAGE extern  const Uint8 firstByteMark[];
 59              
 60              PEGASUS_COMMON_LINKAGE extern  const Uint32 offsetsFromUTF8[];
 61              
 62              PEGASUS_COMMON_LINKAGE extern  const char trailingBytesForUTF8[];
 63 david   1.1  
 64              #define UTF_8_COUNT_TRAIL_BYTES(leadByte) (trailingBytesForUTF8[(Uint8)leadByte])
 65              
 66 chuck   1.4  #define UTF8_NEXT(s, i) { \
 67                  (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \
 68 chip    1.11 }
 69              
 70              PEGASUS_COMMON_LINKAGE Boolean isValid_U8(const Uint8 *src,int size);
 71 david   1.1  
 72 chip    1.11 PEGASUS_COMMON_LINKAGE int UTF16toUTF8(
 73                  const Uint16** srcHead,
 74                  const Uint16* srcEnd,
 75                  Uint8** tgtHead,
 76                  Uint8* tgtEnd);
 77              
 78              PEGASUS_COMMON_LINKAGE int UTF8toUTF16(
 79                  const Uint8** srcHead,
 80                  const Uint8* srcEnd,
 81                  Uint16** tgtHead,
 82                  Uint16* tgtEnd);
 83 david   1.1  
 84 mike    1.13 PEGASUS_COMMON_LINKAGE Boolean isUTF8Aux(const char*);
 85              
 86              inline Boolean isUTF8(const char* c)
 87              {
 88                  return (unsigned int)c[0] < 128 || isUTF8Aux(c);
 89              }
 90 chuck   1.7  
 91 chuck   1.9  PEGASUS_COMMON_LINKAGE Boolean isUTF8Str(const char*);
 92              
 93 chuck   1.7  /** Escape all characters above 7-bit ASCII.
 94                  @param String: The string to be escaped Insert text here.
 95                  @return String: The escaped string.
 96              */
 97              PEGASUS_COMMON_LINKAGE String escapeStringEncoder(const String& Str);
 98              
 99              /** decode string returned from escapeString Encoder.
100                  @param String: The string to be decoded.
101                  @return String: The decoded string.
102              
103 chip    1.11     Prereq: Only the return string from the escapeStringEncoder can be used
104 chuck   1.7              as input.
105              */
106              PEGASUS_COMMON_LINKAGE String escapeStringDecoder(const String& Str);
107              
108 yi.zhou 1.12 /**
109                  The InitializeICU class loads and initializes data items that are required 
110                  internally by various ICU functions. It makes sure that ICU function u_init 
111                  is only called once by a process. A module which is using ICU APIs needs 
112                  to call InitializeICU::initICUSuccessful first before it calls other ICU 
113                  APIs. If InitializeICU::initICUSuccessful is failed, the module should not 
114                  call other ICU APIs. 
115              */
116              
117              #ifdef PEGASUS_HAS_ICU
118              class PEGASUS_COMMON_LINKAGE InitializeICU
119              {
120              public:
121              
122                  /**
123              	Determines if ICU initialization is successful.
124              
125              	@return  true, if u_init is called and success
126              	         false otherwise
127                  */
128              
129 yi.zhou 1.12     static Boolean initICUSuccessful();
130              
131              private:
132                  static Boolean _initAttempted;
133                  static Boolean _initSuccessful;
134              
135                  static Mutex _initMutex;
136              };
137              
138              #endif
139              
140 david   1.5  
141 david   1.1  PEGASUS_NAMESPACE_END
142 chuck   1.2  
143 david   1.1  #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2