Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

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

Generated on Mon Mar 4 22:08:44 2002 for ICU 2.0 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002