-
Extract call to GLib's g_utf8_get_char_validated() and the associated workaround to also read NUL characters into a separate function to make PipeCapture::OnReadable() a little smaller and simpler, so easier to understand. Add max_len > 0 clause into get_utf8_char_validated() like this: if (uc == UTF8_PARTIAL && max_len > 0) so that the NUL character reading workaround is only applied when max_len specifies the maximum number of bytes to read, rather than when -1 specifies reading a NUL termination string. This makes get_utf8_char_validated() a complete wrapper of g_utf8_get_char_validated() [1], even though GParted always specifies the maximum number of bytes to read. No longer describe the inability to read NUL characters as a bug [2] since the GLib author's said it wasn't [3]. [1] GLib Reference Manual, Unicode Manipulation Functions, g_utf8_get_char_validated () https://developer.gnome.org/glib/stable/glib-Unicode-Manipulation.html#g-utf8-get-char-validated [2] 8dbbb47c Workaround g_utf8_get_char_validate() bug with embedded NUL bytes (#777973) [3] Bug 780095 - g_utf8_get_char_validated() stopping at nul byte even for length specified buffers https://bugzilla.gnome.org/show_bug.cgi?id=780095#18 "If g_utf8_get_char_validated() encounters a nul byte in the middle of a string of given longer length, it returns -2, indicating a partial gunichar. That is not the obvious behaviour, but since g_utf8_get_char_validated() has been API for a long time, the behaviour cannot be changed. " Closes #136 - 1.2.0: test suite is failing in test_PipeCapture
b1cad17a