UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
utf8.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 Alexey Vatchenko <av@bsdua.org>
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /*
18  * utf8: implementation of UTF-8 charset encoding (RFC3629).
19  */
20 #ifndef _UTF8_H_
21 #define _UTF8_H_
22 
23 #include <sys/types.h>
24 #include <ugdk/structure/types.h>
25 #include <string>
26 #include <vector>
27 
28 #define UTF8_IGNORE_ERROR 0x01
29 #define UTF8_SKIP_BOM 0x02
30 
31 size_t utf8_to_ucs4(const char *in, size_t insize, char32_t *out,
32  size_t outsize, int flags);
33 size_t ucs4_to_utf8(const char32_t *in, size_t insize, char *out,
34  size_t outsize, int flags);
35 
36 std::u32string utf8_to_ucs4(const std::string& utf8);
37 std::string ucs4_to_utf8(const std::u32string& wstr);
38 
39 #endif /* !_UTF8_H_ */
size_t ucs4_to_utf8(const char32_t *in, size_t insize, char *out, size_t outsize, int flags)
size_t utf8_to_ucs4(const char *in, size_t insize, char32_t *out, size_t outsize, int flags)