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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2