path: root/utf8.h
diff options
authorLars Schneider <>2018-04-15 18:16:05 (GMT)
committerJunio C Hamano <>2018-04-16 02:40:56 (GMT)
commit10ecb82e4f1f507d5f122e00fd4829b30953f853 (patch)
tree58e2245d175a29290fc4405988ab650b5b669207 /utf8.h
parent2f0c4a362c5db677ee392a6a550632bfb22d8319 (diff)
utf8: add function to detect prohibited UTF-16/32 BOM
Whenever a data stream is declared to be UTF-16BE, UTF-16LE, UTF-32BE or UTF-32LE a BOM must not be used [1]. The function returns true if this is the case. This function is used in a subsequent commit. [1] Signed-off-by: Lars Schneider <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'utf8.h')
1 files changed, 9 insertions, 0 deletions
diff --git a/utf8.h b/utf8.h
index 6bbcf31..0db1db4 100644
--- a/utf8.h
+++ b/utf8.h
@@ -70,4 +70,13 @@ typedef enum {
void strbuf_utf8_align(struct strbuf *buf, align_type position, unsigned int width,
const char *s);
+ * If a data stream is declared as UTF-16BE or UTF-16LE, then a UTF-16
+ * BOM must not be used [1]. The same applies for the UTF-32 equivalents.
+ * The function returns true if this rule is violated.
+ *
+ * [1]
+ */
+int has_prohibited_utf_bom(const char *enc, const char *data, size_t len);