diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 17:58:12 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 17:58:12 +0100 |
commit | 0e27aac4f124efcd495469522706df8cc1ca5986 (patch) | |
tree | 728028364c231e0aba5110e6e2a0cef3995812aa /src/main.cpp | |
parent | 36a95838d17ffaee4020a2aba832af6636591df4 (diff) |
Bring back the Polish translation.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index e503cad..f5e7a19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,6 +14,30 @@ uint64_t nano_clock(void) return ts.tv_sec * 1000000000LLU + ts.tv_nsec; } +void utf8_to_wchar(wchar_t *out, size_t size, std::string in) +{ + wchar_t *d = out, *end = out + size; + + for (size_t i = 0; i < in.size(); i++) { + if (d + 1 >= end) + break; + + if ((in[i] & 128) == 0) + *(d++) = in[i]; + else { + if (i + 1 >= in.size()) { + printf("invalid UTF-8 sequence\n"); + abort(); + } + + *(d++) = ((in[i] & 31) << 6) | (in[i + 1] & 63); + i++; + } + } + + *(d++) = 0; +} + int main() { uint64_t t0 = nano_clock(); |