2 * UCW Library: Reading and writing of UTF-8 and UTF-16 on Fastbuf Streams
4 * (c) 2001--2004 Martin Mares <mj@ucw.cz>
5 * (c) 2004 Robert Spalek <robert@ucw.cz>
6 * (c) 2007--2008 Pavel Charvat <pchar@ucw.cz>
8 * This software may be freely distributed and used according to the terms
9 * of the GNU Lesser General Public License.
12 #ifndef _UCW_FF_UNICODE_H
13 #define _UCW_FF_UNICODE_H
15 #include "lib/fastbuf.h"
16 #include "lib/unicode.h"
20 int bget_utf8_slow(struct fastbuf *b, uns repl);
21 int bget_utf8_32_slow(struct fastbuf *b, uns repl);
22 void bput_utf8_slow(struct fastbuf *b, uns u);
23 void bput_utf8_32_slow(struct fastbuf *b, uns u);
26 bget_utf8_repl(struct fastbuf *b, uns repl)
31 b->bptr = utf8_get_repl(b->bptr, &u, repl);
35 return bget_utf8_slow(b, repl);
39 bget_utf8_32_repl(struct fastbuf *b, uns repl)
44 b->bptr = utf8_32_get_repl(b->bptr, &u, repl);
48 return bget_utf8_32_slow(b, repl);
52 bget_utf8(struct fastbuf *b)
54 return bget_utf8_repl(b, UNI_REPLACEMENT);
58 bget_utf8_32(struct fastbuf *b)
60 return bget_utf8_32_repl(b, UNI_REPLACEMENT);
64 bput_utf8(struct fastbuf *b, uns u)
67 b->bptr = utf8_put(b->bptr, u);
73 bput_utf8_32(struct fastbuf *b, uns u)
76 b->bptr = utf8_32_put(b->bptr, u);
78 bput_utf8_32_slow(b, u);
83 int bget_utf16_be_slow(struct fastbuf *b, uns repl);
84 int bget_utf16_le_slow(struct fastbuf *b, uns repl);
85 void bput_utf16_be_slow(struct fastbuf *b, uns u);
86 void bput_utf16_le_slow(struct fastbuf *b, uns u);
89 bget_utf16_be_repl(struct fastbuf *b, uns repl)
94 b->bptr = utf16_be_get_repl(b->bptr, &u, repl);
98 return bget_utf16_be_slow(b, repl);
102 bget_utf16_le_repl(struct fastbuf *b, uns repl)
107 b->bptr = utf16_le_get_repl(b->bptr, &u, repl);
111 return bget_utf16_le_slow(b, repl);
115 bget_utf16_be(struct fastbuf *b)
117 return bget_utf16_be_repl(b, UNI_REPLACEMENT);
121 bget_utf16_le(struct fastbuf *b)
123 return bget_utf16_le_repl(b, UNI_REPLACEMENT);
127 bput_utf16_be(struct fastbuf *b, uns u)
130 b->bptr = utf16_be_put(b->bptr, u);
132 bput_utf16_be_slow(b, u);
136 bput_utf16_lbe(struct fastbuf *b, uns u)
139 b->bptr = utf16_le_put(b->bptr, u);
141 bput_utf16_le_slow(b, u);