Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

utf32.h

Go to the documentation of this file.
00001 /*
00002 *******************************************************************************
00003 *
00004 *   Copyright (C) 1999-2001, International Business Machines
00005 *   Corporation and others.  All Rights Reserved.
00006 *
00007 *******************************************************************************
00008 *   file name:  utf32.h
00009 *   encoding:   US-ASCII
00010 *   tab size:   8 (not used)
00011 *   indentation:4
00012 *
00013 *   created on: 1999sep20
00014 *   created by: Markus W. Scherer
00015 */
00030 #ifndef __UTF32_H__
00031 #define __UTF32_H__
00032 
00033 /* internal definitions ----------------------------------------------------- */
00034 
00035 #define UTF32_IS_SAFE(c, strict) \
00036     ((uint32_t)(c)<=0x10ffff && \
00037      (!(strict) || !UTF_IS_SURROGATE(c) && ((c)&0xfffe)!=0xfffe))
00038 
00039 /*
00040  * For the semantics of all of these macros, see utf16.h.
00041  * The UTF-32 versions are trivial because any code point is
00042  * encoded using exactly one code unit.
00043  */
00044 
00045 /* single-code point definitions -------------------------------------------- */
00046 
00047 /* classes of code unit values */
00048 #define UTF32_IS_SINGLE(uchar) 1
00049 #define UTF32_IS_LEAD(uchar) 0
00050 #define UTF32_IS_TRAIL(uchar) 0
00051 
00052 /* number of code units per code point */
00053 #define UTF32_NEED_MULTIPLE_UCHAR(c) 0
00054 #define UTF32_CHAR_LENGTH(c) 1
00055 #define UTF32_MAX_CHAR_LENGTH 1
00056 
00057 /* average number of code units compared to UTF-16 */
00058 #define UTF32_ARRAY_SIZE(size) (size)
00059 
00060 #define UTF32_GET_CHAR_UNSAFE(s, i, c) { \
00061     (c)=(s)[i]; \
00062 }
00063 
00064 #define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
00065     (c)=(s)[i]; \
00066     if(!UTF32_IS_SAFE(c, strict)) { \
00067         (c)=UTF_ERROR_VALUE; \
00068     } \
00069 }
00070 
00071 /* definitions with forward iteration --------------------------------------- */
00072 
00073 #define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \
00074     (c)=(s)[(i)++]; \
00075 }
00076 
00077 #define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \
00078     (s)[(i)++]=(c); \
00079 }
00080 
00081 #define UTF32_FWD_1_UNSAFE(s, i) { \
00082     ++(i); \
00083 }
00084 
00085 #define UTF32_FWD_N_UNSAFE(s, i, n) { \
00086     (i)+=(n); \
00087 }
00088 
00089 #define UTF32_SET_CHAR_START_UNSAFE(s, i) { \
00090 }
00091 
00092 #define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
00093     (c)=(s)[(i)++]; \
00094     if(!UTF32_IS_SAFE(c, strict)) { \
00095         (c)=UTF_ERROR_VALUE; \
00096     } \
00097 }
00098 
00099 #define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \
00100     if((uint32_t)(c)<=0x10ffff) { \
00101         (s)[(i)++]=(c); \
00102     } else /* c>0x10ffff, write 0xfffd */ { \
00103         (s)[(i)++]=0xfffd; \
00104     } \
00105 }
00106 
00107 #define UTF32_FWD_1_SAFE(s, i, length) { \
00108     ++(i); \
00109 }
00110 
00111 #define UTF32_FWD_N_SAFE(s, i, length, n) { \
00112     if(((i)+=(n))>(length)) { \
00113         (i)=(length); \
00114     } \
00115 }
00116 
00117 #define UTF32_SET_CHAR_START_SAFE(s, start, i) { \
00118 }
00119 
00120 /* definitions with backward iteration -------------------------------------- */
00121 
00122 #define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \
00123     (c)=(s)[--(i)]; \
00124 }
00125 
00126 #define UTF32_BACK_1_UNSAFE(s, i) { \
00127     --(i); \
00128 }
00129 
00130 #define UTF32_BACK_N_UNSAFE(s, i, n) { \
00131     (i)-=(n); \
00132 }
00133 
00134 #define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \
00135 }
00136 
00137 #define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \
00138     (c)=(s)[--(i)]; \
00139     if(!UTF32_IS_SAFE(c, strict)) { \
00140         (c)=UTF_ERROR_VALUE; \
00141     } \
00142 }
00143 
00144 #define UTF32_BACK_1_SAFE(s, start, i) { \
00145     --(i); \
00146 }
00147 
00148 #define UTF32_BACK_N_SAFE(s, start, i, n) { \
00149     (i)-=(n); \
00150     if((i)<(start)) { \
00151         (i)=(start); \
00152     } \
00153 }
00154 
00155 #define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \
00156 }
00157 
00158 #endif

Generated at Tue Jun 12 14:04:03 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000