3 * @brief Conversions between Unicode and local charsets, string
4 * manipulation functions that act on character types.
9 int wctoutf8(char *d, ucs_t s);
10 int utf8towc(ucs_t *d, const char *s);
11 #ifdef TARGET_OS_WINDOWS
12 std::wstring utf8_to_16(const char *s);
13 std::string utf16_to_8(const wchar_t *s);
15 static inline std::wstring utf8_to_16(const std::string &s)
17 return utf8_to_16(s.c_str());
19 static inline std::string utf16_to_8(const std::wstring &s)
21 return utf16_to_8(s.c_str());
24 std::string utf8_to_mb(const char *s);
25 std::string mb_to_utf8(const char *s);
27 static inline std::string utf8_to_mb(const std::string &s)
29 return utf8_to_mb(s.c_str());
31 static inline std::string mb_to_utf8(const std::string &s)
33 return mb_to_utf8(s.c_str());
42 char *prev_glyph(char *s, char *start);
43 char *next_glyph(char *s);
45 #define OUTS(x) utf8_to_mb(x).c_str()
46 #define OUTW(x) utf8_to_16(x).c_str()
51 virtual ~LineInput() {}
52 virtual bool eof() = 0;
53 virtual bool error() { return false; };
54 virtual std::string get_line() = 0;
57 class FileLineInput : public LineInput
61 BOM_NORMAL, // system locale
72 FileLineInput(const char *name);
74 bool eof() { return seen_eof || !f; };
75 bool error() { return !f; };
76 std::string get_line();
79 // The file is always UTF-8, no BOM.
80 // Just read it as-is, merely validating for a well-formed stream.
81 class UTF8FileLineInput : public LineInput
86 UTF8FileLineInput(const char *name);
88 bool eof() { return seen_eof || !f; };
89 bool error() { return !f; };
90 std::string get_line();
93 extern unsigned short charset_vt100[128];
94 extern unsigned short charset_cp437[256];