]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/mbsalign.h
po: update tr.po (from translationproject.org)
[thirdparty/util-linux.git] / include / mbsalign.h
CommitLineData
79feaa60
KZ
1/*
2 * SPDX-License-Identifier: LGPL-2.1-or-later
3 *
4 * Align/Truncate a string in a given screen width
5 * Copyright (C) 2009-2010 Free Software Foundation, Inc.
6 * Copyright (C) 2010-2013 Karel Zak <kzak@redhat.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation, either version 2.1 of the License, or (at your
11 * option) any later version.
12 */
1b1f66e4
KZ
13#ifndef UTIL_LINUX_MBSALIGN_H
14# define UTIL_LINUX_MBSALIGN_H
15# include <stddef.h>
104b92f8
PB
16
17typedef enum { MBS_ALIGN_LEFT, MBS_ALIGN_RIGHT, MBS_ALIGN_CENTER } mbs_align_t;
18
19enum {
20 /* Use unibyte mode for invalid multibyte strings or
21 or when heap memory is exhausted. */
22 MBA_UNIBYTE_FALLBACK = 0x0001,
23
24#if 0 /* Other possible options. */
25 /* Skip invalid multibyte chars rather than failing */
26 MBA_IGNORE_INVALID = 0x0002,
27
28 /* Align multibyte strings using "figure space" (\u2007) */
29 MBA_USE_FIGURE_SPACE = 0x0004,
30
31 /* Don't add any padding */
32 MBA_TRUNCATE_ONLY = 0x0008,
33
34 /* Don't truncate */
35 MBA_PAD_ONLY = 0x0010,
36#endif
37};
38
5f94ca33
KZ
39extern size_t mbs_truncate(char *str, size_t *width);
40
41extern size_t mbsalign (const char *src, char *dest,
42 size_t dest_size, size_t *width,
43 mbs_align_t align, int flags);
1b1f66e4 44
57867795
KZ
45extern size_t mbsalign_with_padding (const char *src, char *dest, size_t dest_size,
46 size_t *width, mbs_align_t align, int flags,
47 int padchar);
48
0c33fcbf 49extern size_t mbs_safe_nwidth(const char *buf, size_t bufsz, size_t *sz);
1b1f66e4 50extern size_t mbs_safe_width(const char *s);
c426f70f 51
0957fdca
KZ
52extern size_t mbs_nwidth(const char *buf, size_t bufsz);
53extern size_t mbs_width(const char *s);
54
1b1f66e4 55extern char *mbs_safe_encode(const char *s, size_t *width);
ff471d89 56extern char *mbs_safe_encode_to_buffer(const char *s, size_t *width, char *buf, const char *safechars);
c426f70f 57extern size_t mbs_safe_encode_size(size_t bytes);
6b724741 58extern size_t mbs_safe_decode_size(const char *s);
1b1f66e4 59
365ed9f6
KZ
60extern char *mbs_invalid_encode(const char *s, size_t *width);
61extern char *mbs_invalid_encode_to_buffer(const char *s, size_t *width, char *buf);
62
1b1f66e4 63#endif /* UTIL_LINUX_MBSALIGN_H */