Files
kichikuou_system3-sdl2/src/encoding.h
T
kichikuou 14d0033db3 Add support for UTF-8 encoded scenario files
If `encoding = utf8` is specified in system3.ini, system3-sdl2 uses
UTF-8 as its multibyte character encoding. It will be used to run games
translated into non-(Japanese|English) languages.
2021-09-04 15:21:52 +09:00

31 lines
844 B
C++

#ifndef _ENCODING_H_
#define _ENCODING_H_
#include <memory>
class Encoding {
public:
static std::unique_ptr<Encoding> create(const char* name);
virtual ~Encoding() = default;
// Returns Unicode codepoint of the first character of *s, and advances *s
// to the next character.
virtual int next_codepoint(const unsigned char** s) = 0;
int next_codepoint(const char** s) {
return next_codepoint(reinterpret_cast<const unsigned char **>(s));
}
// Returns byte length of the first character of s.
virtual int mblen(const unsigned char* s) = 0;
int mblen(const char* s) {
return mblen(reinterpret_cast<const unsigned char*>(s));
}
// Returns the number of characters in s.
int mbslen(const unsigned char* s);
int mbslen(const char* s) {
return mbslen(reinterpret_cast<const unsigned char*>(s));
}
};
#endif // _ENCODING_H_