summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/misc.c21
-rw-r--r--src/core/misc.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 952c7149..3a3b76bb 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -506,3 +506,24 @@ int dec2octal(int decimal)
return octal;
}
+
+/* convert all low-ascii (<32) to ^<A..> combinations */
+char *show_lowascii(const char *channel)
+{
+ char *str, *p;
+
+ str = p = g_malloc(strlen(channel)*2+1);
+ while (*channel != '\0') {
+ if ((unsigned char) *channel >= 32)
+ *p++ = *channel;
+ else {
+ *p++ = '^';
+ *p++ = *channel + 'A'-1;
+ }
+ channel++;
+ }
+ *p = '\0';
+
+ return str;
+}
+
diff --git a/src/core/misc.h b/src/core/misc.h
index 7fa866df..37a19c07 100644
--- a/src/core/misc.h
+++ b/src/core/misc.h
@@ -65,4 +65,7 @@ char *replace_chars(char *str, char from, char to);
int octal2dec(int octal);
int dec2octal(int decimal);
+/* convert all low-ascii (<32) to ^<A..> combinations */
+char *show_lowascii(const char *channel);
+
#endif