@deffn Function g-main-depth  @result{}@tie{} (ret@tie{}@code{int})
Return value: The main loop recursion level in the current thread

The value returned is the depth of the stack of calls to
@code{g-main-context-dispatch} on any @code{<g-main-context>} in the
current thread. That is, when called from the toplevel, it gives 0.
When called from within a callback from
@code{g-main-context-iteration} (or @code{g-main-loop-run}, etc.) it
returns 1. When called from within a callback to a recursive call to
@code{g-main-context-iterate}, it returns 2. And so forth.

This function is an attractive nuisance, and its use normally
indicates a misunderstanding of how main loop reentrancy works. Use
@code{gtk-widget-set-sensitive} or modal dialogs to prevent the user
from interacting with elements while the main loop is recursing.

A better idea is to avoid main loop recursion entirely. Instead,
structure your code so that you simply return to the main loop and
then get called again when there is more work to do.

@end deffn

@deffn Function g-convert  (str@tie{}@code{mchars}) (len@tie{}@code{ssize_t}) (to_codeset@tie{}@code{mchars}) (from_codeset@tie{}@code{mchars}) @result{}@tie{} (ret@tie{}@code{mchars}) (bytes_read@tie{}@code{size_t}) (bytes_written@tie{}@code{size_t})
Converts a string from one character set to another.

@table @var
@item str
the string to convert

@item to-codeset
name of character set into which to convert @var{str}

@item from-codeset
character set of @var{str}.

@item ret
If the conversion was successful, a string. Otherwise an exception
will be thrown.

@end table

Note that some encodings may allow nul bytes to occur inside strings. In that
case, the Guile wrapper for this function is unsafe.

@end deffn

@deffn Function g-convert-with-fallback  (str@tie{}@code{mchars}) (len@tie{}@code{ssize_t}) (to_codeset@tie{}@code{mchars}) (from_codeset@tie{}@code{mchars}) (fallback@tie{}@code{mchars}) @result{}@tie{} (ret@tie{}@code{mchars}) (bytes_read@tie{}@code{size_t}) (bytes_written@tie{}@code{size_t})
Converts a string from one character set to another, possibly including fallback
sequences for characters not representable in the output. Note that it is not
guaranteed that the specification for the fallback sequences in @var{fallback}
will be honored. Some systems may do a approximate conversion from
@var{from-codeset} to @var{to-codeset} in their @code{iconv} functions, in which
case GLib will simply return that approximate conversion.

@table @var
@item str
the string to convert

@item to-codeset
name of character set into which to convert @var{str}

@item from-codeset
character set of @var{str}.

@item fallback
UTF-8 string to use in place of character not present in the target encoding.
(The string must be representable in the target encoding). If @samp{@code{#f}},
characters not in the target encoding will be represented as Unicode escapes
\uxxxx or \Uxxxxyyyy.

@item ret
If the conversion was successful, a string. Otherwise an exception
will be thrown.

@end table

@end deffn

@deffn Function g-locale-to-utf8  (opsysstring@tie{}@code{mchars}) (len@tie{}@code{ssize_t}) @result{}@tie{} (ret@tie{}@code{mchars}) (bytes_read@tie{}@code{size_t}) (bytes_written@tie{}@code{size_t})
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
into a UTF-8 string.

@table @var
@item opsysstring
a string in the encoding of the current locale. On Windows this means the system
codepage.

@item ret
The converted string. If the conversion fails, an exception will be
raised.

@end table

@end deffn

@deffn Function g-locale-from-utf8  (utf8string@tie{}@code{mchars}) (len@tie{}@code{ssize_t}) @result{}@tie{} (ret@tie{}@code{mchars}) (bytes_read@tie{}@code{size_t}) (bytes_written@tie{}@code{size_t})
Converts a string from UTF-8 to the encoding used for strings by the C runtime
(usually the same as that used by the operating system) in the current locale.

@table @var
@item utf8string
a UTF-8 encoded string

@item ret
The converted string. If the conversion fails, an exception will be
raised.

@end table

@end deffn

@deffn Function g-filename-to-utf8  (opsysstring@tie{}@code{mchars}) (len@tie{}@code{ssize_t}) @result{}@tie{} (ret@tie{}@code{mchars}) (bytes_read@tie{}@code{size_t}) (bytes_written@tie{}@code{size_t})
Converts a string which is in the encoding used by GLib for filenames into a
UTF-8 string. Note that on Windows GLib uses UTF-8 for filenames.

@table @var
@item opsysstring
a string in the encoding for filenames

@item ret
The converted string. If the conversion fails, an exception will be
raised.

@end table

@end deffn
