+{
+ /* Illegal to print to the current stream if it is NULL */
+ g_return_if_fail(current_stream != NULL);
+ glk_put_string_stream(current_stream, s);
+}
+
+/**
+ * glk_put_buffer:
+ * @buf: An array of characters in Latin-1 encoding.
+ * @len: Length of @buf.
+ *
+ * Prints @buf to the current stream.
+ */
+void
+glk_put_buffer(char *buf, glui32 len)
+{
+ /* Illegal to print to the current stream if it is NULL */
+ g_return_if_fail(current_stream != NULL);
+ glk_put_buffer_stream(current_stream, buf, len);
+}
+
+/**
+ * glk_put_char_stream:
+ * @str: An output stream.
+ * @ch: A character in Latin-1 encoding.
+ *
+ * Prints one character @ch to the stream @str. It is illegal for @str to be
+ * #NULL, or an input-only stream.
+ */
+void
+glk_put_char_stream(strid_t str, unsigned char ch)
+{
+ g_return_if_fail(str != NULL);
+ g_return_if_fail(str->file_mode != filemode_Read);
+
+ /* Convert ch to a null-terminated string, call glk_put_string_stream() */
+ gchar *s = g_strndup((gchar *)&ch, 1);
+ glk_put_string_stream(str, s);
+ g_free(s);
+}
+
+/* Internal function: change illegal (control) characters in a string to a
+placeholder character. Must free returned string afterwards. */
+static gchar *
+remove_latin1_control_characters(gchar *s)
+{
+ gchar *retval = g_strdup(s);
+ unsigned char *ptr;
+ for(ptr = (unsigned char *)retval; *ptr != '\0'; ptr++)
+ if( (*ptr < 32 && *ptr != 10) || (*ptr >= 127 && *ptr <= 159) )
+ *ptr = '?';
+ /* Our placeholder character is '?'; other options are possible,
+ like printing "0x7F" or something */
+ return retval;
+}
+
+/* Internal function: convert a Latin-1 string to a UTF-8 string, replacing
+Latin-1 control characters by a placeholder first. The UTF-8 string must be
+freed afterwards. Returns NULL on error. */
+static gchar *
+convert_latin1_to_utf8(gchar *s)