diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-07-01 20:29:54 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-07-01 20:42:34 +0200 |
commit | 149bde4dfba07d3d13f531ac63c69d9c6af1989b (patch) | |
tree | d06799ce2515161691968c0b8b036484b3cd9473 /crawl-ref/source/unicode.cc | |
parent | 767e31263185364de0cf201098569a8c5fb34ff0 (diff) | |
download | crawl-ref-149bde4dfba07d3d13f531ac63c69d9c6af1989b.tar.gz crawl-ref-149bde4dfba07d3d13f531ac63c69d9c6af1989b.zip |
Don't use locale-dependent %ls.
While webtiles are not supported on Windows, and no sane Unix uses encodings
other than UTF-8, we can have local webtiles some day.
Diffstat (limited to 'crawl-ref/source/unicode.cc')
-rw-r--r-- | crawl-ref/source/unicode.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/crawl-ref/source/unicode.cc b/crawl-ref/source/unicode.cc index 1d83f65edd..aa6773ba21 100644 --- a/crawl-ref/source/unicode.cc +++ b/crawl-ref/source/unicode.cc @@ -233,6 +233,23 @@ static std::string utf8_validate(const char *s) return d; } +#ifdef USE_TILE_WEB +std::string wcstoutf8(const std::wstring &s) +{ + std::string out; + + for (size_t j = 0; j < s.length(); j++) + { + char buf[4]; + int r = wctoutf8(buf, s[j]); + for (int i = 0; i < r; j++) + out.push_back(buf[i]); + } + + return out; +} +#endif + static bool _check_trail(FILE *f, const char* bytes, int len) { while (len--) |