Multi-byte String manipulation functions. More...
#include "config.h"
#include <ctype.h>
#include <stdbool.h>
#include <stddef.h>
#include <wctype.h>
Go to the source code of this file.
Macros | |
#define | IsPrint(ch) (isprint((unsigned char) (ch)) || (OptLocales ? 0 : ((unsigned char) (ch) >= 0xa0))) |
#define | IsWPrint(wc) (iswprint(wc) || (OptLocales ? 0 : (wc >= 0xa0))) |
Functions | |
int | mutt_mb_charlen (const char *s, int *width) |
Count the bytes in a (multibyte) character. | |
int | mutt_mb_filter_unprintable (char **s) |
Replace unprintable characters. | |
bool | mutt_mb_get_initials (const char *name, char *buf, size_t buflen) |
Turn a name into initials. | |
bool | mutt_mb_is_display_corrupting_utf8 (wchar_t wc) |
Will this character corrupt the display? | |
bool | mutt_mb_is_lower (const char *s) |
Does a multi-byte string contain only lowercase characters? | |
bool | mutt_mb_is_shell_char (wchar_t ch) |
Is character not typically part of a pathname. | |
size_t | mutt_mb_mbstowcs (wchar_t **pwbuf, size_t *pwbuflen, size_t i, const char *buf) |
Convert a string from multibyte to wide characters. | |
void | buf_mb_wcstombs (struct Buffer *dest, const wchar_t *wstr, size_t wlen) |
Convert a string from wide to multibyte characters. | |
int | mutt_mb_wcswidth (const wchar_t *s, size_t n) |
Measure the screen width of a string. | |
int | mutt_mb_wcwidth (wchar_t wc) |
Measure the screen width of a character. | |
int | mutt_mb_width (const char *str, int col, bool indent) |
Measure a string's display width (in screen columns) | |
size_t | mutt_mb_width_ceiling (const wchar_t *s, size_t n, int w1) |
Keep the end of the string on-screen. | |
Variables | |
bool | OptLocales |
(pseudo) set if user has valid locale definition | |
Multi-byte String manipulation functions.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file mbyte.h.
#define IsPrint | ( | ch | ) | (isprint((unsigned char) (ch)) || (OptLocales ? 0 : ((unsigned char) (ch) >= 0xa0))) |
#define IsWPrint | ( | wc | ) | (iswprint(wc) || (OptLocales ? 0 : (wc >= 0xa0))) |
int mutt_mb_charlen | ( | const char * | s, |
int * | width | ||
) |
Count the bytes in a (multibyte) character.
[in] | s | String to be examined |
[out] | width | Number of screen columns the character would use |
num | Bytes in the first (multibyte) character of input consumes |
<0 | Conversion error |
=0 | End of input |
>0 | Length (bytes) |
Definition at line 55 of file mbyte.c.
int mutt_mb_filter_unprintable | ( | char ** | s | ) |
Replace unprintable characters.
[in,out] | s | String to modify |
0 | Success |
-1 | Error |
Unprintable characters will be replaced with ReplacementChar.
Definition at line 423 of file mbyte.c.
bool mutt_mb_get_initials | ( | const char * | name, |
char * | buf, | ||
size_t | buflen | ||
) |
Turn a name into initials.
name | String to be converted |
buf | Buffer for the result |
buflen | Size of the buffer |
1 | Success |
0 | Failure |
Take a name, e.g. "John F. Kennedy" and reduce it to initials "JFK". The function saves the first character from each word. Words are delimited by whitespace, or hyphens (so "Jean-Pierre" becomes "JP").
Definition at line 82 of file mbyte.c.
bool mutt_mb_is_display_corrupting_utf8 | ( | wchar_t | wc | ) |
Will this character corrupt the display?
wc | Character to examine |
true | Character would corrupt the display |
false | Character is safe to display |
Definition at line 385 of file mbyte.c.
bool mutt_mb_is_lower | ( | const char * | s | ) |
Does a multi-byte string contain only lowercase characters?
s | String to check |
true | String contains no uppercase characters |
false | Error, or contains some uppercase characters |
Non-alphabetic characters are considered lowercase.
Definition at line 354 of file mbyte.c.
bool mutt_mb_is_shell_char | ( | wchar_t | ch | ) |
Is character not typically part of a pathname.
ch | Character to examine |
true | Character is not typically part of a pathname |
false | Character is typically part of a pathname |
Definition at line 340 of file mbyte.c.
size_t mutt_mb_mbstowcs | ( | wchar_t ** | pwbuf, |
size_t * | pwbuflen, | ||
size_t | i, | ||
const char * | buf | ||
) |
Convert a string from multibyte to wide characters.
[out] | pwbuf | Buffer for the result |
[out] | pwbuflen | Length of the result buffer |
[in] | i | Starting index into the result buffer |
[in] | buf | String to convert |
num | First character after the result |
Definition at line 291 of file mbyte.c.
void buf_mb_wcstombs | ( | struct Buffer * | dest, |
const wchar_t * | wstr, | ||
size_t | wlen | ||
) |
Convert a string from wide to multibyte characters.
dest | Buffer for the result |
wstr | Source wide string to convert |
wlen | Length of the wide string |
Definition at line 256 of file mbyte.c.
int mutt_mb_wcswidth | ( | const wchar_t * | s, |
size_t | n | ||
) |
Measure the screen width of a string.
s | String to measure |
n | Length of string in characters |
num | Width in screen columns |
Definition at line 216 of file mbyte.c.
int mutt_mb_wcwidth | ( | wchar_t | wc | ) |
Measure the screen width of a character.
wc | Character to examine |
num | Width in screen columns |
Definition at line 198 of file mbyte.c.
int mutt_mb_width | ( | const char * | str, |
int | col, | ||
bool | indent | ||
) |
Measure a string's display width (in screen columns)
str | String to measure |
col | Display column (used for expanding tabs) |
indent | If true, newline-space will be indented 8 chars |
num | String's width in screen columns |
This is like wcwidth(), but gets const char* not wchar_t*.
Definition at line 137 of file mbyte.c.
size_t mutt_mb_width_ceiling | ( | const wchar_t * | s, |
size_t | n, | ||
int | w1 | ||
) |
Keep the end of the string on-screen.
s | String being displayed |
n | Length of string in characters |
w1 | Width limit |
num | Chars to skip |
Given a string and a width, determine how many characters from the beginning of the string should be skipped so that the string fits.
Definition at line 237 of file mbyte.c.