mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
string: add BOM helper
This commit is contained in:
parent
afc22ec539
commit
3704c4a012
@ -541,3 +541,16 @@ string_is_utf8(const char *str, size_t len)
|
|||||||
}
|
}
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
|
@ -53,5 +53,6 @@ const char *find_str_at_start_of_line(const char *haystack,
|
|||||||
int string_is_C_identifier(const char *string);
|
int string_is_C_identifier(const char *string);
|
||||||
|
|
||||||
int string_is_utf8(const char *str, size_t len);
|
int string_is_utf8(const char *str, size_t len);
|
||||||
|
int string_is_utf8_no_bom(const char *str, size_t len);
|
||||||
|
|
||||||
#endif /* !defined(TOR_UTIL_STRING_H) */
|
#endif /* !defined(TOR_UTIL_STRING_H) */
|
||||||
|
Loading…
Reference in New Issue
Block a user