mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
string: add BOM helper
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user