mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Localization: Make Qt's locale-aware formatting accessible from C
This commit introduces functions: - QString asprintf_loc(const char *cformat, ...); - int snprintf_loc(char *dst, size_t size, const char *cformat, ...); - put_format_loc(struct membuffer *, const char *fmt, ...); and their va_arg equivalents, which use Qt's QString::arg() formatting options to render the strings. The snprintf_loc() function takes care not to truncate multi-byte UTF-8 encodings. Thus, on overflow, the resulting string might be shorter than size-1. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9a8a0afa29
commit
bec3e80683
4 changed files with 421 additions and 3 deletions
|
@ -22,6 +22,7 @@ struct membuffer {
|
|||
|
||||
extern char *detach_buffer(struct membuffer *b);
|
||||
extern void free_buffer(struct membuffer *);
|
||||
extern void make_room(struct membuffer *b, unsigned int size);
|
||||
extern void flush_buffer(struct membuffer *, FILE *);
|
||||
extern void put_bytes(struct membuffer *, const char *, int);
|
||||
extern void put_string(struct membuffer *, const char *);
|
||||
|
@ -29,7 +30,9 @@ extern void put_quoted(struct membuffer *, const char *, int, int);
|
|||
extern void strip_mb(struct membuffer *);
|
||||
extern const char *mb_cstring(struct membuffer *);
|
||||
extern __printf(2, 0) void put_vformat(struct membuffer *, const char *, va_list);
|
||||
extern __printf(2, 0) void put_vformat_loc(struct membuffer *, const char *, va_list);
|
||||
extern __printf(2, 3) void put_format(struct membuffer *, const char *fmt, ...);
|
||||
extern __printf(2, 3) void put_format_loc(struct membuffer *, const char *fmt, ...);
|
||||
extern __printf(2, 0) char *add_to_string_va(const char *old, const char *fmt, va_list args);
|
||||
extern __printf(2, 3) char *add_to_string(const char *old, const char *fmt, ...);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue