str is the text to validate; if str is nul-terminated, then max_len can be
-1, otherwise max_len should be the number of bytes to validate.
If end is non-NULL, then the end of the valid range will be stored there.
This is the first byte of the first invalid character if some bytes were
invalid, or the end of the text being validated otherwise — either the
trailing nul byte, or the first byte beyond max_len (if it’s positive).
Note that g_utf8_validate() returns FALSE if max_len is positive and
any of the max_len bytes are nul.
Returns TRUE if all of str was valid. Many GLib and GTK
routines require valid UTF-8 as input; so data read from a file
or the network should be checked with g_utf8_validate() before
doing anything else with it.
Validates UTF-8 encoded text.
stris the text to validate; ifstris nul-terminated, thenmax_lencan be-1, otherwisemax_lenshould be the number of bytes to validate.If
endis non-NULL, then the end of the valid range will be stored there. This is the first byte of the first invalid character if some bytes were invalid, or the end of the text being validated otherwise — either the trailing nul byte, or the first byte beyondmax_len(if it’s positive).Note that
g_utf8_validate()returnsFALSEifmax_lenis positive and any of themax_lenbytes are nul.Returns
TRUEif all ofstrwas valid. Many GLib and GTK routines require valid UTF-8 as input; so data read from a file or the network should be checked withg_utf8_validate()before doing anything else with it.