(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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #ifndef Pegasus_CommonUTF_h
 35            #define Pegasus_CommonUTF_h
 36            #include <Pegasus/Common/Config.h>
 37 chuck 1.6  #include <Pegasus/Common/Linkage.h>
 38 chuck 1.7  #include <Pegasus/Common/String.h>
 39 mike  1.16 #include <Pegasus/Common/Mutex.h>
 40 david 1.1  
 41            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 karl  1.17 PEGASUS_COMMON_LINKAGE extern const Uint32 halfBase;
 52            PEGASUS_COMMON_LINKAGE extern  const Uint32 halfMask;
 53            PEGASUS_COMMON_LINKAGE extern  const int halfShift;
 54            PEGASUS_COMMON_LINKAGE extern  const Uint8 firstByteMark[];
 55            
 56            PEGASUS_COMMON_LINKAGE extern  const Uint32 offsetsFromUTF8[];
 57            
 58            PEGASUS_COMMON_LINKAGE extern  const char trailingBytesForUTF8[];
 59 david 1.1  
 60 kumpf 1.18 #define UTF_8_COUNT_TRAIL_BYTES(leadByte) \
 61                (trailingBytesForUTF8[(Uint8)leadByte])
 62 david 1.1  
 63 chuck 1.4  #define UTF8_NEXT(s, i) { \
 64                (i)=((i) + UTF_8_COUNT_TRAIL_BYTES((s)[(i)]) + 1); \
 65 chip  1.11 }
 66            
 67            PEGASUS_COMMON_LINKAGE Boolean isValid_U8(const Uint8 *src,int size);
 68 david 1.1  
 69 chip  1.11 PEGASUS_COMMON_LINKAGE int UTF16toUTF8(
 70                const Uint16** srcHead,
 71                const Uint16* srcEnd,
 72                Uint8** tgtHead,
 73                Uint8* tgtEnd);
 74            
 75            PEGASUS_COMMON_LINKAGE int UTF8toUTF16(
 76                const Uint8** srcHead,
 77                const Uint8* srcEnd,
 78                Uint16** tgtHead,
 79                Uint16* tgtEnd);
 80 david 1.1  
 81 mike  1.13 PEGASUS_COMMON_LINKAGE Boolean isUTF8Aux(const char*);
 82            
 83            inline Boolean isUTF8(const char* c)
 84            {
 85                return (unsigned int)c[0] < 128 || isUTF8Aux(c);
 86            }
 87 chuck 1.7  
 88 chuck 1.9  PEGASUS_COMMON_LINKAGE Boolean isUTF8Str(const char*);
 89            
 90 chuck 1.7  /** 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 chip  1.11     Prereq: Only the return string from the escapeStringEncoder can be used
101 chuck 1.7              as input.
102            */
103            PEGASUS_COMMON_LINKAGE String escapeStringDecoder(const String& Str);
104            
105 yi.zhou 1.12 /**
106 kumpf   1.18     The InitializeICU class loads and initializes data items that are required
107                  internally by various ICU functions. It makes sure that ICU function u_init
108                  is only called once by a process. A module which is using ICU APIs needs
109                  to call InitializeICU::initICUSuccessful first before it calls other ICU
110                  APIs. If InitializeICU::initICUSuccessful is failed, the module should not
111                  call other ICU APIs.
112 yi.zhou 1.12 */
113              
114              #ifdef PEGASUS_HAS_ICU
115              class PEGASUS_COMMON_LINKAGE InitializeICU
116              {
117              public:
118              
119                  /**
120 kumpf   1.18         Determines if ICU initialization is successful.
121 yi.zhou 1.12 
122 kumpf   1.18         @return  true, if u_init is called and success
123                               false otherwise
124 yi.zhou 1.12     */
125              
126                  static Boolean initICUSuccessful();
127              
128              private:
129                  static Boolean _initAttempted;
130                  static Boolean _initSuccessful;
131              
132                  static Mutex _initMutex;
133              };
134              
135              #endif
136              
137 david   1.5  
138 david   1.1  PEGASUS_NAMESPACE_END
139 chuck   1.2  
140 david   1.1  #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2