Function

GLibprintf_string_upper_bound

Declaration [src]

gsize
g_printf_string_upper_bound (
  const gchar* format,
  va_list args
)

Description [src]

Calculates the maximum space needed to store the output of the sprintf() function.

If format or args are invalid, 0 is returned. This could happen if, for example, format contains an %lc or %ls placeholder and args contains a wide character which cannot be represented in multibyte encoding. 0 can also be returned legitimately if, for example, format is %s and args is an empty string. The caller is responsible for differentiating these two return cases if necessary. It is recommended to not use %lc or %ls placeholders in any case, as their behaviour is locale-dependent.

This function is not directly available to language bindings.

Parameters

format

Type: const gchar*

The format string. See the printf() documentation.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
args

Type: va_list

The parameters to be inserted into the format string.

Return value

Type: gsize

The maximum space needed to store the formatted string, or 0 on error.