Cogs.Core
utf8_strings.h
1#ifndef LH_UTF8_STRINGS_H
2#define LH_UTF8_STRINGS_H
3
4namespace litehtml
5{
7 {
8 const byte* m_utf8;
9 std::wstring m_str;
10 public:
11 utf8_to_wchar(const char* val);
12 operator const wchar_t*() const
13 {
14 return m_str.c_str();
15 }
16 private:
17 ucode_t getb()
18 {
19 if (!(*m_utf8)) return 0;
20 return *m_utf8++;
21 }
22 ucode_t get_next_utf8(ucode_t val)
23 {
24 return (val & 0x3f);
25 }
26 ucode_t get_char();
27 };
28
30 {
31 std::string m_str;
32 public:
33 wchar_to_utf8(const wchar_t* val);
34 operator const char*() const
35 {
36 return m_str.c_str();
37 }
38 };
39
40#ifdef LITEHTML_UTF8
41#define litehtml_from_utf8(str) str
42#define litehtml_to_utf8(str) str
43#define litehtml_from_wchar(str) wchar_to_utf8(str)
44#else
45#define litehtml_from_utf8(str) utf8_to_wchar(str)
46#define litehtml_from_wchar(str) str
47#define litehtml_to_utf8(str) wchar_to_utf8(str)
48#endif
49}
50
51#endif // LH_UTF8_STRINGS_H