aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_latin.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-01-25 21:03:48 +0100
committerMattias Andrée <m@maandree.se>2026-01-25 21:03:48 +0100
commitb710c7eb580d8f291bee9bc760d806ec305f26b2 (patch)
tree30f50ee2832a80d37a4a9615ccec543bdfd6a79b /libcharconv_latin.c
parentlatin: do not covert LF and SP to text (diff)
downloadcharconv-b710c7eb580d8f291bee9bc760d806ec305f26b2.tar.gz
charconv-b710c7eb580d8f291bee9bc760d806ec305f26b2.tar.bz2
charconv-b710c7eb580d8f291bee9bc760d806ec305f26b2.tar.xz
Add control character representations
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcharconv_latin.c')
-rw-r--r--libcharconv_latin.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libcharconv_latin.c b/libcharconv_latin.c
index 360b3dd..047dee5 100644
--- a/libcharconv_latin.c
+++ b/libcharconv_latin.c
@@ -449,6 +449,17 @@ libcharconv_latin(const char *s, size_t slen, size_t *n, uint_least32_t *cp, siz
c = (uint_least32_t)"gaehrcsGAEHRCS"[c - UINT32_C(0x1FA60)];
goto conv;
+ } else if (UINT32_C(0x2400) <= c && c <= UINT32_C(0x2421)) {
+ /* control character representations */
+ cs = ((const char *[]){
+ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
+ "BS", "HT", "LF", " VT", "FF", "CR", "SS", "SI",
+ "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
+ "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
+ "SP", "DEL"
+ })[c & 0xFF];
+ goto conv_str;
+
} else {
use_switch:
switch (c) {