summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/unicode.h
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-12-18 12:11:34 +0100
committerAdam Borowski <kilobyte@angband.pl>2010-12-18 12:11:34 +0100
commitd562ab002f5aad0a15d8e94830aa710f78c52513 (patch)
treeb6976a8854946aac28d972a64285114ec6daa673 /crawl-ref/source/unicode.h
parentbbc1968de451ed0b88b7a11f5ab302bf3ede5df7 (diff)
downloadcrawl-ref-d562ab002f5aad0a15d8e94830aa710f78c52513.tar.gz
crawl-ref-d562ab002f5aad0a15d8e94830aa710f78c52513.zip
Get rid of one last use of fstream.
The database files are assumed to be always in UTF-8. This can make editing them harder on Windows (some editors do cope, even notepad), but assuming the system's locale would break running directly from git without installing. Current uses are merely: (all in quotes.txt) * "Alain René" * "Rabbi Löw" * "Öland" * "Min son på galejan" * typographical apostrophes but it's likely it will be a bigger issue in the future (and if we ever do translations, a lot bigger).
Diffstat (limited to 'crawl-ref/source/unicode.h')
-rw-r--r--crawl-ref/source/unicode.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/crawl-ref/source/unicode.h b/crawl-ref/source/unicode.h
index e9eb164856..0cb1c08507 100644
--- a/crawl-ref/source/unicode.h
+++ b/crawl-ref/source/unicode.h
@@ -62,4 +62,18 @@ public:
std::string get_line();
};
+// The file is always UTF-8, no BOM.
+// Just read it as-is, merely validating for a well-formed stream.
+class UTF8FileLineInput : public LineInput
+{
+ FILE *f;
+ bool seen_eof;
+public:
+ UTF8FileLineInput(const char *name);
+ ~UTF8FileLineInput();
+ bool eof() { return seen_eof || !f; };
+ bool error() { return !f; };
+ std::string get_line();
+};
+
#endif