summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/win1252enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/win1252enc.c')
-rw-r--r--zap/source/amd64/mem/win1252enc.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/zap/source/amd64/mem/win1252enc.c b/zap/source/amd64/mem/win1252enc.c
new file mode 100644
index 0000000..cd313cd
--- /dev/null
+++ b/zap/source/amd64/mem/win1252enc.c
@@ -0,0 +1,113 @@
+/*
+ Copyright 2022 Gabriel Jensen.
+ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+ If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+*/
+
+#include <zap/priv.h>
+
+#include <zap/mem.h>
+
+void zap_win1252enc(zap_chr20 const * const _in,zap_chr8 * const _out) {
+ zap_chr20 const * in = _in;
+ zap_chr8 * out = _out;
+ for (;;++in,++out) {
+ zap_chr20 const chr = *in;
+ zap_chr8 const bad = 0x3Fu;
+ switch (chr) {
+ default:
+ if (chr > 0xFFu) {
+ *out = bad;
+ break;
+ }
+ if (chr >= 0x80u && chr <= 0x9Fu) {
+ *out = bad;
+ break;
+ }
+ *out = *in;
+ break;
+ case 0x20ACu:
+ *out = 0x80u;
+ break;
+ case 0x201Au:
+ *out = 0x82u;
+ break;
+ case 0x192u:
+ *out = 0x83u;
+ break;
+ case 0x201Eu:
+ *out = 0x84u;
+ break;
+ case 0x2026u:
+ *out = 0x85u;
+ break;
+ case 0x2020u:
+ *out = 0x86u;
+ break;
+ case 0x2021u:
+ *out = 0x87u;
+ break;
+ case 0x2C6u:
+ *out = 0x88u;
+ break;
+ case 0x2030u:
+ *out = 0x89u;
+ break;
+ case 0x160u:
+ *out = 0x8Au;
+ break;
+ case 0x2039u:
+ *out = 0x8Bu;
+ break;
+ case 0x152u:
+ *out = 0x8Cu;
+ break;
+ case 0x17Du:
+ *out = 0x8Eu;
+ break;
+ case 0x2018u:
+ *out = 0x91u;
+ break;
+ case 0x2019u:
+ *out = 0x92u;
+ break;
+ case 0x201Cu:
+ *out = 0x93u;
+ break;
+ case 0x201Du:
+ *out = 0x94u;
+ break;
+ case 0x2022u:
+ *out = 0x95u;
+ break;
+ case 0x2013u:
+ *out = 0x96u;
+ break;
+ case 0x2014u:
+ *out = 0x97u;
+ break;
+ case 0x2DCu:
+ *out = 0x98u;
+ break;
+ case 0x2122u:
+ *out = 0x99u;
+ break;
+ case 0x161u:
+ *out = 0x9Au;
+ break;
+ case 0x203Au:
+ *out = 0x9Bu;
+ break;
+ case 0x153u:
+ *out = 0x9Cu;
+ break;
+ case 0x17Eu:
+ *out = 0x9Eu;
+ break;
+ case 0x178u:
+ *out = 0x9Fu;
+ break;
+ }
+ if (chr == 0x0u) {break;}
+ }
+}