2 * UCW Library: Reading and writing of UTF-8 on Fastbuf Streams
4 * (c) 2001--2004 Martin Mares <mj@ucw.cz>
5 * (c) 2004 Robert Spalek <robert@ucw.cz>
7 * This software may be freely distributed and used according to the terms
8 * of the GNU Lesser General Public License.
11 #ifndef _UCW_FF_UTF8_H
12 #define _UCW_FF_UTF8_H
14 #include "lib/fastbuf.h"
15 #include "lib/unicode.h"
19 int bget_utf8_slow(struct fastbuf *b, uns repl);
20 int bget_utf8_32_slow(struct fastbuf *b, uns repl);
21 void bput_utf8_slow(struct fastbuf *b, uns u);
22 void bput_utf8_32_slow(struct fastbuf *b, uns u);
25 bget_utf8_repl(struct fastbuf *b, uns repl)
30 b->bptr = utf8_get_repl(b->bptr, &u, repl);
34 return bget_utf8_slow(b, repl);
38 bget_utf8_32_repl(struct fastbuf *b, uns repl)
43 b->bptr = utf8_32_get_repl(b->bptr, &u, repl);
47 return bget_utf8_32_slow(b, repl);
51 bget_utf8(struct fastbuf *b)
53 return bget_utf8_repl(b, UNI_REPLACEMENT);
57 bget_utf8_32(struct fastbuf *b)
59 return bget_utf8_32_repl(b, UNI_REPLACEMENT);
63 bput_utf8(struct fastbuf *b, uns u)
66 b->bptr = utf8_put(b->bptr, u);
72 bput_utf8_32(struct fastbuf *b, uns u)
75 b->bptr = utf8_32_put(b->bptr, u);
77 bput_utf8_32_slow(b, u);
82 int bget_utf16_be_slow(struct fastbuf *b, uns repl);
83 int bget_utf16_le_slow(struct fastbuf *b, uns repl);
84 void bput_utf16_be_slow(struct fastbuf *b, uns u);
85 void bput_utf16_le_slow(struct fastbuf *b, uns u);
88 bget_utf16_be_repl(struct fastbuf *b, uns repl)
93 b->bptr = utf16_be_get_repl(b->bptr, &u, repl);
97 return bget_utf16_be_slow(b, repl);
101 bget_utf16_le_repl(struct fastbuf *b, uns repl)
106 b->bptr = utf16_le_get_repl(b->bptr, &u, repl);
110 return bget_utf16_le_slow(b, repl);
114 bget_utf16_be(struct fastbuf *b)
116 return bget_utf16_be_repl(b, UNI_REPLACEMENT);
120 bget_utf16_le(struct fastbuf *b)
122 return bget_utf16_le_repl(b, UNI_REPLACEMENT);
126 bput_utf16_be(struct fastbuf *b, uns u)
129 b->bptr = utf16_be_put(b->bptr, u);
131 bput_utf16_be_slow(b, u);
135 bput_utf16_lbe(struct fastbuf *b, uns u)
138 b->bptr = utf16_le_put(b->bptr, u);
140 bput_utf16_le_slow(b, u);