diff options
author | Adam Borowski <kilobyte@angband.pl> | 2010-12-16 15:09:40 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2010-12-16 16:53:03 +0100 |
commit | 64ca3ade493233cf0d4c43dfc68cf22622d23b76 (patch) | |
tree | 0779de71d31ab8390c93db4ea9b9a05c842b2dad /crawl-ref/source/unicode.h | |
parent | 851cdeb3d20406d126469933afefbec5e233a417 (diff) | |
download | crawl-ref-64ca3ade493233cf0d4c43dfc68cf22622d23b76.tar.gz crawl-ref-64ca3ade493233cf0d4c43dfc68cf22622d23b76.zip |
A reader for Windows-style BOMmed files.
Diffstat (limited to 'crawl-ref/source/unicode.h')
-rw-r--r-- | crawl-ref/source/unicode.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crawl-ref/source/unicode.h b/crawl-ref/source/unicode.h index 92600d4534..5de066ea99 100644 --- a/crawl-ref/source/unicode.h +++ b/crawl-ref/source/unicode.h @@ -24,3 +24,25 @@ static inline std::string mb_to_utf8(const std::string &s) } #define OUTS(x) utf8_to_mb(x).c_str() + +class TextFileReader +{ + enum bom_type + { + BOM_NORMAL, // system locale + BOM_UTF8, + BOM_UTF16LE, + BOM_UTF16BE, + BOM_UTF32LE, + BOM_UTF32BE, + }; + FILE *f; + bom_type bom; + bool seen_eof; +public: + TextFileReader(const char *name); + ~TextFileReader(); + bool eof() { return seen_eof; }; + bool error() { return !f; }; + std::string get_line(); +}; |