summaryrefslogtreecommitdiff
path: root/zap/source/any/mem/win1252enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/any/mem/win1252enc.c')
-rw-r--r--zap/source/any/mem/win1252enc.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/zap/source/any/mem/win1252enc.c b/zap/source/any/mem/win1252enc.c
new file mode 100644
index 0000000..f773540
--- /dev/null
+++ b/zap/source/any/mem/win1252enc.c
@@ -0,0 +1,113 @@
+/*
+ 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/mem.h>
+
+void zap_win1252enc(zap_chr8 * const _dest,zap_chr02 const * const _src) {
+ zap_chr8 * dest;
+ zap_chr02 const * src;
+ for (dest = _dest,src = _src;;++src,++dest) {
+ zap_chr02 const chr = *src;
+ if (chr == 0x0u) {
+ break;
+ }
+ zap_chr8 const bad = 0x3Fu;
+ switch (chr) {
+ default:
+ if (chr > 0xFFu) {
+ *dest = bad;
+ break;
+ }
+ if (chr >= 0x80u && chr <= 0x9Fu) {
+ *dest = bad;
+ break;
+ }
+ *dest = *src;
+ break;
+ case 0x20ACu:
+ *dest = 0x80u;
+ break;
+ case 0x201Au:
+ *dest = 0x82u;
+ break;
+ case 0x192u:
+ *dest = 0x83u;
+ break;
+ case 0x201Eu:
+ *dest = 0x84u;
+ break;
+ case 0x2026u:
+ *dest = 0x85u;
+ break;
+ case 0x2020u:
+ *dest = 0x86u;
+ break;
+ case 0x2021u:
+ *dest = 0x87u;
+ break;
+ case 0x2C6u:
+ *dest = 0x88u;
+ break;
+ case 0x2030u:
+ *dest = 0x89u;
+ break;
+ case 0x160u:
+ *dest = 0x8Au;
+ break;
+ case 0x2039u:
+ *dest = 0x8Bu;
+ break;
+ case 0x152u:
+ *dest = 0x8Cu;
+ break;
+ case 0x17Du:
+ *dest = 0x8Eu;
+ break;
+ case 0x2018u:
+ *dest = 0x91u;
+ break;
+ case 0x2019u:
+ *dest = 0x92u;
+ break;
+ case 0x201Cu:
+ *dest = 0x93u;
+ break;
+ case 0x201Du:
+ *dest = 0x94u;
+ break;
+ case 0x2022u:
+ *dest = 0x95u;
+ break;
+ case 0x2013u:
+ *dest = 0x96u;
+ break;
+ case 0x2014u:
+ *dest = 0x97u;
+ break;
+ case 0x2DCu:
+ *dest = 0x98u;
+ break;
+ case 0x2122u:
+ *dest = 0x99u;
+ break;
+ case 0x161u:
+ *dest = 0x9Au;
+ break;
+ case 0x203Au:
+ *dest = 0x9Bu;
+ break;
+ case 0x153u:
+ *dest = 0x9Cu;
+ break;
+ case 0x17Eu:
+ *dest = 0x9Eu;
+ break;
+ case 0x178u:
+ *dest = 0x9Fu;
+ break;
+ }
+ }
+}