Function glib::locale_to_utf8
source · pub fn locale_to_utf8(opsysstring: &[u8]) -> Result<(GString, usize), CvtError>Expand description
Converts a string which is in the encoding used for strings by the C runtime (usually the same as that used by the operating system) in the [current locale][setlocale] into a UTF-8 string.
If the source encoding is not UTF-8 and the conversion output contains a
nul character, the error ConvertError::EmbeddedNul is set and the
function returns None.
If the source encoding is UTF-8, an embedded nul character is treated with
the ConvertError::IllegalSequence error for backward compatibility with
earlier versions of this library. Use convert() to produce output that
may contain embedded nul characters.
opsysstring
a string in the encoding of the current locale. On Windows this means the system codepage.
Returns
The converted string, or None on an error.
bytes_read
location to store the number of bytes in the
input string that were successfully converted, or None.
Even if the conversion was successful, this may be
less than len if there were partial characters
at the end of the input. If the error
ConvertError::IllegalSequence occurs, the value
stored will be the byte offset after the last valid
input sequence.
bytes_written
the number of bytes stored in the output buffer (not including the terminating nul).