aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-20 16:32:14 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-20 16:32:14 -0500
commitb757a7b42d6c54f431c31642cfbe0127e77cf822 (patch)
treed8a79dbb22e51ad1143959e04793e9bb016789b6
parentd74816a16b1594279aae19a11ca6581ac0a05dd5 (diff)
downloaduxd-b757a7b42d6c54f431c31642cfbe0127e77cf822.tar.gz
better printable forms of invalid unicode
-rw-r--r--uxd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/uxd.c b/uxd.c
index 7724669..3b899be 100644
--- a/uxd.c
+++ b/uxd.c
@@ -84,6 +84,9 @@ extern int optind;
/* replacement character � is U+FFFD */
#define PRINT_BAD "�"
#define PRINT_BOM "B"
+#define PRINT_OLONG "O"
+#define PRINT_OORANGE "+"
+#define PRINT_SURR "S"
/* sprintf() formats for hex data */
#define LC_BYTE_FMT "%02x"
@@ -643,25 +646,25 @@ char *classify_char(int *hl, unsigned char *bytes, int cont_count) {
} else {
*hl = HL_BAD;
}
- return PRINT_BAD;
+ return PRINT_OLONG;
}
if(is_surrogate(cont_count, bytes)) {
if(wtf8_mode || permissive) {
- *hl = HL_NORMAL;
+ *hl = HL_SPECIAL;
} else {
*hl = HL_BAD;
}
- return PRINT_BAD;
+ return PRINT_SURR;
}
if(is_out_of_range(cont_count, bytes)) {
if(permissive) {
- *hl = HL_NORMAL;
+ *hl = HL_SPECIAL;
} else {
*hl = HL_BAD;
}
- return PRINT_BAD;
+ return PRINT_OORANGE;
}
*hl = HL_NORMAL;