]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/osrf_utf8.h
Eliminated four dead functions that are never called
[OpenSRF.git] / include / opensrf / osrf_utf8.h
1 /*----------------------------------------------------
2  Desc    : functions and macros for processing UTF-8
3  Author  : Scott McKellar
4  Notes   : 
5
6  Copyright 2008 Scott McKellar
7  All Rights reserved
8  
9  Date       Change
10  ---------- -----------------------------------------
11  2008/11/20 Initial creation
12  ---------------------------------------------------*/
13
14 #ifndef OSRF_UTF8_H
15 #define OSRF_UTF8_H
16
17 extern unsigned char osrf_utf8_mask_[];  // Lookup table of bitmasks
18
19 // Meanings of the various bit switches:
20
21 #define UTF8_CONTROL  0x01
22 #define UTF8_PRINT    0x02
23 #define UTF8_CONTINUE 0x04
24 #define UTF8_2_BYTE   0x08
25 #define UTF8_3_BYTE   0x10
26 #define UTF8_4_BYTE   0x20
27 #define UTF8_SYNC     0x40
28 #define UTF8_VALID    0x80
29
30 // macros:
31
32 #define is_utf8_control( x )  ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_CONTROL )
33 #define is_utf8_print( x )    ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_PRINT )
34 #define is_utf8_continue( x ) ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_CONTINUE )
35 #define is_utf8_2_byte( x )   ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_2_BYTE )
36 #define is_utf8_3_byte( x )   ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_3_BYTE )
37 #define is_utf8_4_byte( x )   ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_4_BYTE )
38 #define is_utf8_sync( x )     ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_SYNC )
39 #define is_utf8( x )          ( osrf_utf8_mask_[ (x) & 0xFF ] & UTF8_VALID )
40
41 // Equivalent functions, for when you need a function pointer
42
43 int is__utf8__control( int c );
44 int is__utf8__print( int c );
45 int is__utf8__continue( int c );
46 int is__utf8__2_byte( int c );
47 int is__utf8__3_byte( int c );
48 int is__utf8__4_byte( int c );
49 int is__utf8__sync( int c );
50 int is__utf8( int c );
51
52 // Translate a string, escaping as needed, and append the
53 // result to a growing_buffer
54
55 int buffer_append_utf8( growing_buffer* buf, const char* string );
56
57 #endif