summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/win1252dec.c
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/win1252dec.c')
-rw-r--r--zap/source/amd64/mem/win1252dec.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/zap/source/amd64/mem/win1252dec.c b/zap/source/amd64/mem/win1252dec.c
new file mode 100644
index 0000000..2a5e897
--- /dev/null
+++ b/zap/source/amd64/mem/win1252dec.c
@@ -0,0 +1,111 @@
+/*
+ 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_win1252dec(zap_chr8 const * const _in,zap_chr20 * const _out) {
+ zap_chr8 const * in = _in;
+ zap_chr20 * out = _out;
+ for (;;++in,++out) {
+ zap_chr8 const chr = *in;
+ switch (chr) {
+ default:
+ *out = *in;
+ break;
+ case 0x81: /* Bad characters. */
+ case 0x8D:
+ case 0x8F:
+ case 0x90:
+ case 0x9D:
+ *out = 0xFFFDu; /* REPLACEMENT CHARACTER */
+ break;
+ case 0x80:
+ *out = 0x20ACu;
+ break;
+ case 0x82:
+ *out = 0x201Au;
+ break;
+ case 0x83:
+ *out = 0x192u;
+ break;
+ case 0x84:
+ *out = 0x201Eu;
+ break;
+ case 0x85:
+ *out = 0x2026u;
+ break;
+ case 0x86:
+ *out = 0x2020u;
+ break;
+ case 0x87:
+ *out = 0x2021u;
+ break;
+ case 0x88:
+ *out = 0x2C6u;
+ break;
+ case 0x89:
+ *out = 0x2030u;
+ break;
+ case 0x8A:
+ *out = 0x160u;
+ break;
+ case 0x8B:
+ *out = 0x2039u;
+ break;
+ case 0x8C:
+ *out = 0x152u;
+ break;
+ case 0x8E:
+ *out = 0x17Du;
+ break;
+ case 0x91:
+ *out = 0x2018u;
+ break;
+ case 0x92:
+ *out = 0x2019u;
+ break;
+ case 0x93:
+ *out = 0x201Cu;
+ break;
+ case 0x94:
+ *out = 0x201Du;
+ break;
+ case 0x95:
+ *out = 0x2022u;
+ break;
+ case 0x96:
+ *out = 0x2013u;
+ break;
+ case 0x97:
+ *out = 0x2014u;
+ break;
+ case 0x98:
+ *out = 0x2DCu;
+ break;
+ case 0x99:
+ *out = 0x2122u;
+ break;
+ case 0x9A:
+ *out = 0x161u;
+ break;
+ case 0x9B:
+ *out = 0x203Au;
+ break;
+ case 0x9C:
+ *out = 0x153u;
+ break;
+ case 0x9E:
+ *out = 0x17Eu;
+ break;
+ case 0x9F:
+ *out = 0x178u;
+ break;
+ }
+ if (chr == 0x0u) {break;}
+ }
+}