Multi-byte String manipulation functions. More...
#include "config.h"#include <limits.h>#include <stdbool.h>#include <string.h>#include <wchar.h>#include <wctype.h>#include "mbyte.h"#include "buffer.h"#include "charset.h"#include "ctype2.h"#include "memory.h"#include "pool.h"#include "string2.h"Go to the source code of this file.
Functions | |
| int | mutt_mb_charlen (const char *s, int *width) |
| Count the bytes in a (multibyte) character. | |
| bool | mutt_mb_get_initials (const char *name, char *buf, size_t buflen) |
| Turn a name into initials. | |
| int | mutt_mb_width (const char *str, int col, bool indent) |
| Measure a string's display width (in screen columns). | |
| int | mutt_mb_wcwidth (wchar_t wc) |
| Measure the screen width of a character. | |
| int | mutt_mb_wcswidth (const wchar_t *s, size_t n) |
| Measure the screen width of a string. | |
| size_t | mutt_mb_width_ceiling (const wchar_t *s, size_t n, int w1) |
| Keep the end of the string on-screen. | |
| void | buf_mb_wcstombs (struct Buffer *dest, const wchar_t *wstr, size_t wlen) |
| Convert a string from wide to multibyte characters. | |
| 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. | |
| bool | mutt_mb_is_shell_char (wchar_t ch) |
| Is character not typically part of a pathname. | |
| bool | mutt_mb_is_lower (const char *s) |
| Does a multi-byte string contain only lowercase characters? | |
| bool | mutt_mb_is_display_corrupting_utf8 (wchar_t wc) |
| Will this character corrupt the display? | |
| int | mutt_mb_filter_unprintable (char **s) |
| Replace unprintable characters. | |
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.c.
| 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 56 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 83 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 138 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 199 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 217 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 238 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 257 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 292 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 341 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 355 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 386 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 424 of file mbyte.c.