freeform_string_to_utf8
Description:
Convenience function to read a string with unknown character encoding.
If the string is already in UTF-8 encoding, it will be returned right away. If not it tries to detect byte-order-mark for UTF-16/32 cases and
use that. Otherwise, the environment will be searched for a number of environment variables (whose names are specified in the NULL-terminated
string array env_vars
) containing a list of character encodings to try/use. If none are specified, the current locale will be
tried. If that also doesn't work, WINDOWS-1252/ISO-8859-1 is assumed (which will almost always succeed).
Parameters:
data |
string data |
env_vars |
a NULL-terminated string array of environment variable names, or NULL |
size |
length of string data, or -1 if the string is NUL-terminated |
Returns:
a newly-allocated string in UTF-8 encoding, or NULL |