Previous 199869 Revisions Next

r26156 Thursday 14th November, 2013 at 10:13:04 UTC by Jürgen Buchmüller
Clean up and wrap NEED_UNICODE_... macros in #ifndef for makefile support
[/branches/alto2/src/lib/util]unicode.c unicode.h

branches/alto2/src/lib/util/unicode.c
r26155r26156
350350   The expected format is "Format A" defined
351351   by unicode.org
352352-------------------------------------------------*/
353unicode_char* unicode_load_table(const char* name)
353unicode_char * uchar_table_load(const char* name)
354354{
355355   FILE* file = fopen(name, "r");
356356   if (NULL == file)
r26155r26156
384384   return table;
385385}
386386
387void unicode_free_table(unicode_char* table)
387UINT8 uchar_table_index(unicode_char* table, unicode_char uchar)
388388{
389   UINT8 index;
390   for (index = 0; index < 254; index++)
391      if (uchar == table[index])
392         return index;
393   return index;
394}
395
396void uchar_table_free(unicode_char* table)
397{
389398   if (table)
390399      free(table);
391400}
branches/alto2/src/lib/util/unicode.h
r26155r26156
9090const char *utf8_previous_char(const char *utf8string);
9191int utf8_is_valid_string(const char *utf8string);
9292
93/* Unicode lookup table loader */
94//! load a table translating UINT8 (unsigned char) to Unicode values
95unicode_char * uchar_table_load(const char* name);
96
97//! reverse lookup of uchar in a Unicode table - returns 255 if not found
98UINT8 uchar_table_index(unicode_char* table, unicode_char uchar);
99
100//! free a unicode table
101void uchar_table_free(unicode_char* table);
102
93103/***************************************************************************
94 *   unicode.org published UnicodeData.txt parser and accessors
104 *   unicode.org published UnicodeData.txt
105 *  parser and accessors
95106 ***************************************************************************/
96107
108//! load the UnicodeData.txt file an parse it
109int unicode_data_load(const char* name);
110
111//! free the UnicodeData.txt table memory
112void unicode_data_free();
113
97114//! size of the first 17 Unicode planes
98115#define   UNICODE_PLANESIZE      0x110000
99116
117#ifndef   NEED_UNICODE_RANGES
100118#define   NEED_UNICODE_RANGES      1      //!< define to 1, if the name, first or last of the range of a code is needed
119#endif
120
121#ifndef   NEED_UNICODE_NAME
101122#define   NEED_UNICODE_NAME      1      //!< define to 1, if the name of a code is needed
123#endif
124
125#ifndef   NEED_UNICODE_NAME10
102126#define   NEED_UNICODE_NAME10      1      //!< define to 1, if the short name of a code is needed
127#endif
128
129#ifndef   NEED_UNICODE_GCAT
103130#define   NEED_UNICODE_GCAT      1      //!< define to 1, if the general category of a code is needed
131#endif
132
133#ifndef   NEED_UNICODE_CCOM
104134#define   NEED_UNICODE_CCOM      1      //!< define to 1, if the canonical combining (name) of a code is needed
135#endif
136
137#ifndef   NEED_UNICODE_BIDI
105138#define   NEED_UNICODE_BIDI      1      //!< define to 1, if the bidirectional category of a code is needed
139#endif
140
141#ifndef   NEED_UNICODE_DECO
106142#define   NEED_UNICODE_DECO      1      //!< define to 1, if the decomposition codes of a code are needed
143#endif
144
145#ifndef   NEED_UNICODE_DECIMAL
107146#define   NEED_UNICODE_DECIMAL   1      //!< define to 1, if the decimal value of a code is needed
147#endif
148
149#ifndef   NEED_UNICODE_DIGIT
108150#define   NEED_UNICODE_DIGIT      1      //!< define to 1, if the digit value of a code is needed
151#endif
152
153#ifndef   NEED_UNICODE_NUMERIC
109154#define   NEED_UNICODE_NUMERIC   1      //!< define to 1, if the numeric value of a code is needed
155#endif
156
157#ifndef   NEED_UNICODE_MIRRORED
110158#define   NEED_UNICODE_MIRRORED   1      //!< define to 1, if the mirrored flag of a code is needed
159#endif
160
161#ifndef   NEED_UNICODE_DECN
111162#define   NEED_UNICODE_DECN      1      //!< define to 1, if access to decomposed code [n] of a code is needed
163#endif
164
165#ifndef   NEED_UNICODE_UCASE
112166#define   NEED_UNICODE_UCASE      1      //!< define to 1, if the upper case value of a code is needed
167#endif
168
169#ifndef   NEED_UNICODE_LCASE
113170#define   NEED_UNICODE_LCASE      1      //!< define to 1, if the lower case value of a code is needed
171#endif
172
173#ifndef   NEED_UNICODE_TCASE
114174#define   NEED_UNICODE_TCASE      1      //!< define to 1, if the title case value of a code is needed
175#endif
176
177#ifndef   NEED_UNICODE_WIDTH
115178#define   NEED_UNICODE_WIDTH      1      //!< define to 1, if the glyph width of a code is needed
179#endif
116180
117181#if   NEED_UNICODE_GCAT
118182typedef enum {
r26155r26156
292356int unicode_width(unicode_char uchar);
293357#endif
294358
295//! load the UnicodeData.txt file an parse it
296int unicode_data_load(const char* name);
297
298//! free the parse UnicodeData.txt memory
299void unicode_data_free();
300
301359/***************************************************************************
302360   MACROS
303361***************************************************************************/

Previous 199869 Revisions Next


© 1997-2024 The MAME Team