blob: d7ae548d78025ed01e1ac22fd41d214d0d91a001 (
plain) (
tree)
|
|
/*
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_win1252enc(zap_i8 * dest,zap_i02 const * src) {
for (;;++src,++dest) {
zap_i02 const chr = *src;
if (chr == 0x0u) break;
zap_i8 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;
}
}
}
|