## GtkDataFormat GtkDataFormat — a data formatting library |

## Functions

gchar * | gtk_data_format ()
gchar * | gtk_data_format_remove ()

## Includes

    #include <gtkextra.h>

## Description

the widget property 'dataformat' may contain formatting instructions for the field contents. Any unrecognized formatting instruction is silently skipped.

The formatting process should always be reversible. Thus formatting can be applied when input focus leaves a field and removed again when the focus enters a field, without the need of an additional content buffer.

the library can be easily extended by adding more instructions to the list above.

## Functions

### gtk_data_format ()

    gchar *
    gtk_data_format (const gchar *str,
                     const gchar *dataformat);

format `str` according to `dataformat` .

formatting instructions:

'' (the empty string) does no formatting at all.

'int8' is formatted as a singed 8-bit integer value with optional '-' sign.

'int16' is formatted as a signed 16-bit integer with optional '-' sign.

'int32' is formatted as a signed 32-bit integer with optional '-' sign.

'money' is formatted as a double float value with 2 decimal digits and 1000s-separators

'float,N' is formatted as a double float value with N decimal digits and 1000s-separators

'bit' is formatted as a boolean value [0,1].

#### Parameters

str | the string to be formatted |
dataformat | formatting instructions |

#### Returns

a pointer to an internal static buffer, with the formatted data

### gtk_data_format_remove ()

    gchar *
    gtk_data_format_remove (const gchar *str,
                            const gchar *dataformat);

reverse the effect of gtk_data_format, i.e. remove all formatting characters, apply trailing dash

#### Parameters

str | the string to be unformatted |
dataformat | formatting instructions |

#### Returns

a pointer to an internal static buffer, with the unformatted data

## Types and Values