aboutsummaryrefslogtreecommitdiff
path: root/src/lib/string/util_string.c
diff options
context:
space:
mode:
authorcypherpunks <cypherpunks@torproject.org>2018-08-29 13:32:52 +0000
committercypherpunks <cypherpunks@torproject.org>2018-10-23 00:33:48 +0000
commit3704c4a01219cca7273fa5fa0bc6751d98ad05ac (patch)
treec6b88808549535fadcdba6bd6d93d9e951433f44 /src/lib/string/util_string.c
parentafc22ec5396e677c8cc3f7f14ecec7dc02a75b63 (diff)
downloadtor-3704c4a01219cca7273fa5fa0bc6751d98ad05ac.tar.gz
tor-3704c4a01219cca7273fa5fa0bc6751d98ad05ac.zip
string: add BOM helper
Diffstat (limited to 'src/lib/string/util_string.c')
-rw-r--r--src/lib/string/util_string.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/string/util_string.c b/src/lib/string/util_string.c
index b2b85d151d..e76e73046f 100644
--- a/src/lib/string/util_string.c
+++ b/src/lib/string/util_string.c
@@ -541,3 +541,16 @@ string_is_utf8(const char *str, size_t len)
}
return true;
}
+
+/** As string_is_utf8(), but returns false if the string begins with a UTF-8
+ * byte order mark (BOM).
+ */
+int
+string_is_utf8_no_bom(const char *str, size_t len)
+{
+ if (len >= 3 && (!strcmpstart(str, "\uFEFF") ||
+ !strcmpstart(str, "\uFFFE"))) {
+ return false;
+ }
+ return string_is_utf8(str, len);
+}