aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/bfc/string/utf8.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/bfc/string/utf8.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Wasabi/bfc/string/utf8.cpp')
-rw-r--r--Src/Wasabi/bfc/string/utf8.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/string/utf8.cpp b/Src/Wasabi/bfc/string/utf8.cpp
new file mode 100644
index 00000000..389c231f
--- /dev/null
+++ b/Src/Wasabi/bfc/string/utf8.cpp
@@ -0,0 +1,25 @@
+#include "precomp_wasabi_bfc.h"
+
+#include "utf8.h"
+
+// this STILL doesn't work perfectly but at least it decodes what we write out
+// mostly just waiting on our wide character strategy
+
+void COMEXP UTF8_to_ASCII(const char *in, char *out) {
+ unsigned const char *src = (unsigned const char *)in;
+ unsigned char *dst = (unsigned char *)out;
+ *dst = 0;
+ for (; *src; src++) {
+ int c = *src;
+ if ((c & 0x80) == 0) {
+ *dst++ = c;
+ continue;
+ }
+ if ((c & 224) != 192) continue; // fuck you, we only check for single bytes
+ int v = (c & 0x3) << 6;
+ ++src;
+ v |= *src & 0x3f;
+ *dst++ = v;
+ }
+ *dst = 0;
+}