diff --git a/docs/reference/glib/programming.xml b/docs/reference/glib/programming.xml index 2c38fee5d..9efa19d33 100644 --- a/docs/reference/glib/programming.xml +++ b/docs/reference/glib/programming.xml @@ -30,6 +30,36 @@ to test all the allocation failure code paths. + +UTF-8 and String Encoding + + +All GLib, GObject and GIO functions accept and return strings in +UTF-8 encoding +unless otherwise specified. + + + +Input strings to function calls are not checked to see if +they are valid UTF-8: it is the application developer’s responsibility to +validate input strings at the time of input, either at the program or library +boundary, and to only use valid UTF-8 string constants in their application. +If GLib were to UTF-8 validate all string inputs to all functions, there would +be a significant drop in performance. + + +Similarly, output strings from functions are guaranteed to be in UTF-8, +and this does not need to be validated by the calling function. If a function +returns invalid UTF-8 (and is not documented as doing so), that’s a bug. + + + +See g_utf8_validate() +and g_utf8_make_valid() +for validating UTF-8 input. + + + Threads