summaryrefslogtreecommitdiff
path: root/src/core/utf8.h
diff options
context:
space:
mode:
authorXavier G <xavier.github@kindwolf.org>2016-05-13 02:10:02 +0200
committerXavier G <xavier.github@kindwolf.org>2016-05-13 02:10:02 +0200
commit2c8648a9c889fc0a7c4b24367a3f81f08dedccb2 (patch)
tree40b589aa69d286cdce41778f05115a64861d0c0b /src/core/utf8.h
parentb0afcc96dbc13cf3a5ed94686bb227ab0d86ceaa (diff)
downloadirssi-2c8648a9c889fc0a7c4b24367a3f81f08dedccb2.zip
Introduce string_policy().
Diffstat (limited to 'src/core/utf8.h')
-rw-r--r--src/core/utf8.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/utf8.h b/src/core/utf8.h
index 50ee0886..fa11b737 100644
--- a/src/core/utf8.h
+++ b/src/core/utf8.h
@@ -19,6 +19,20 @@ int mk_wcwidth(unichar c);
*/
int string_advance(char const **str, gboolean utf8);
+/* TREAT_STRING_AS_BYTES means strings are to be treated using strncpy,
+ * strnlen, etc.
+ * TREAT_STRING_AS_UTF8 means strings are to be treated using g_utf8_*
+ * functions.
+ */
+#define TREAT_STRING_AS_BYTES 0
+#define TREAT_STRING_AS_UTF8 1
+
+/* Return how the str string ought to be treated: TREAT_STRING_AS_UTF8 if the
+ * terminal handles UTF-8 and if the string appears to be a valid UTF-8 string;
+ * TREAT_STRING_AS_BYTES otherwise.
+ */
+int string_policy(const char *str);
+
#define unichar_isprint(c) (((c) & ~0x80) >= 32)
#define is_utf8_leading(c) (((c) & 0xc0) != 0x80)