summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
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();