summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Griffis <pgriffis@igalia.com>2023-05-02 19:20:30 +0000
committerPatrick Griffis <pgriffis@igalia.com>2023-05-02 19:20:30 +0000
commitde2ff264540b892a7eac26805010cf27fbb28a39 (patch)
treee690b728a4e31be514ba59b47a6bb1e0e8b222e0
parent8725d6ef4c356abd035472f0adb96cc8b591c8b7 (diff)
parent0e941418d139a77a0a505f28e42562bd20b452ba (diff)
downloadglib-de2ff264540b892a7eac26805010cf27fbb28a39.tar.gz
Merge branch '116-utf8-docs' into 'main'
docs: Document high-level UTF-8 requirements for GLib Closes #116 See merge request GNOME/glib!3414
-rw-r--r--docs/reference/glib/programming.xml30
1 files changed, 30 insertions, 0 deletions
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
@@ -31,6 +31,36 @@ to test all the allocation failure code paths.
</refsect2>
<refsect2>
+<title>UTF-8 and String Encoding</title>
+
+<para>
+All GLib, GObject and GIO functions accept and return strings in
+<ulink url="https://en.wikipedia.org/wiki/UTF-8">UTF-8 encoding</ulink>
+unless otherwise specified.
+</para>
+
+<para>
+Input strings to function calls are <emphasis>not</emphasis> 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.
+</para>
+
+<para>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.
+</para>
+
+<para>
+See <link linkend='g-utf8-validate'><function>g_utf8_validate()</function></link>
+and <link linkend='g-utf8-make-valid'><function>g_utf8_make_valid()</function></link>
+for validating UTF-8 input.
+</para>
+</refsect2>
+
+<refsect2>
<title>Threads</title>
<para>