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