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-2000, 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 */
00027 #ifndef __UTF32_H__
00028 #define __UTF32_H__
00029 
00030 /* internal definitions ----------------------------------------------------- */
00031 
00032 #define UTF32_IS_SAFE(c, strict) \
00033     ((uint32_t)(c)<=0x10ffff && \
00034      (!(strict) || !UTF_IS_SURROGATE(c) && ((c)&0xfffe)!=0xfffe))
00035 
00036 /*
00037  * For the semantics of all of these macros, see utf16.h.
00038  * The UTF-32 versions are trivial because any code point is
00039  * encoded using exactly one code unit.
00040  */
00041 
00042 /* single-code point definitions -------------------------------------------- */
00043 
00044 /* classes of code unit values */
00045 #define UTF32_IS_SINGLE(uchar) 1
00046 #define UTF32_IS_LEAD(uchar) 0
00047 #define UTF32_IS_TRAIL(uchar) 0
00048 
00049 /* number of code units per code point */
00050 #define UTF32_NEED_MULTIPLE_UCHAR(c) 0
00051 #define UTF32_CHAR_LENGTH(c) 1
00052 #define UTF32_MAX_CHAR_LENGTH 1
00053 
00054 /* average number of code units compared to UTF-16 */
00055 #define UTF32_ARRAY_SIZE(size) (size)
00056 
00057 #define UTF32_GET_CHAR_UNSAFE(s, i, c) { \
00058     (c)=(s)[i]; \
00059 }
00060 
00061 #define UTF32_GET_CHAR_SAFE(s, start, i, length, c, strict) { \
00062     (c)=(s)[i]; \
00063     if(!UTF32_IS_SAFE(c, strict)) { \
00064         (c)=UTF_ERROR_VALUE; \
00065     } \
00066 }
00067 
00068 /* definitions with forward iteration --------------------------------------- */
00069 
00070 #define UTF32_NEXT_CHAR_UNSAFE(s, i, c) { \
00071     (c)=(s)[(i)++]; \
00072 }
00073 
00074 #define UTF32_APPEND_CHAR_UNSAFE(s, i, c) { \
00075     (s)[(i)++]=(c); \
00076 }
00077 
00078 #define UTF32_FWD_1_UNSAFE(s, i) { \
00079     ++(i); \
00080 }
00081 
00082 #define UTF32_FWD_N_UNSAFE(s, i, n) { \
00083     (i)+=(n); \
00084 }
00085 
00086 #define UTF32_SET_CHAR_START_UNSAFE(s, i) { \
00087 }
00088 
00089 #define UTF32_NEXT_CHAR_SAFE(s, i, length, c, strict) { \
00090     (c)=(s)[(i)++]; \
00091     if(!UTF32_IS_SAFE(c, strict)) { \
00092         (c)=UTF_ERROR_VALUE; \
00093     } \
00094 }
00095 
00096 #define UTF32_APPEND_CHAR_SAFE(s, i, length, c) { \
00097     if((uint32_t)(c)<=0x10ffff) { \
00098         (s)[(i)++]=(c); \
00099     } else /* c>0x10ffff, write 0xfffd */ { \
00100         (s)[(i)++]=0xfffd; \
00101     } \
00102 }
00103 
00104 #define UTF32_FWD_1_SAFE(s, i, length) { \
00105     ++(i); \
00106 }
00107 
00108 #define UTF32_FWD_N_SAFE(s, i, length, n) { \
00109     if(((i)+=(n))>(length)) { \
00110         (i)=(length); \
00111     } \
00112 }
00113 
00114 #define UTF32_SET_CHAR_START_SAFE(s, start, i) { \
00115 }
00116 
00117 /* definitions with backward iteration -------------------------------------- */
00118 
00119 #define UTF32_PREV_CHAR_UNSAFE(s, i, c) { \
00120     (c)=(s)[--(i)]; \
00121 }
00122 
00123 #define UTF32_BACK_1_UNSAFE(s, i) { \
00124     --(i); \
00125 }
00126 
00127 #define UTF32_BACK_N_UNSAFE(s, i, n) { \
00128     (i)-=(n); \
00129 }
00130 
00131 #define UTF32_SET_CHAR_LIMIT_UNSAFE(s, i) { \
00132 }
00133 
00134 #define UTF32_PREV_CHAR_SAFE(s, start, i, c, strict) { \
00135     (c)=(s)[--(i)]; \
00136     if(!UTF32_IS_SAFE(c, strict)) { \
00137         (c)=UTF_ERROR_VALUE; \
00138     } \
00139 }
00140 
00141 #define UTF32_BACK_1_SAFE(s, start, i) { \
00142     --(i); \
00143 }
00144 
00145 #define UTF32_BACK_N_SAFE(s, start, i, n) { \
00146     (i)-=(n); \
00147     if((i)<(start)) { \
00148         (i)=(start); \
00149     } \
00150 }
00151 
00152 #define UTF32_SET_CHAR_LIMIT_SAFE(s, i, length) { \
00153 }
00154 
00155 #endif

Generated at Fri Dec 15 12:12:39 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000