Rizin
unix-like reverse engineering framework and cli tools
|
Utility functions for handling multibyte strings. More...
#include "tuklib_common.h"
Go to the source code of this file.
Macros | |
#define | tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width) |
#define | tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw) |
Functions | |
size_t | tuklib_mbstr_width (const char *str, size_t *bytes) |
Get the number of columns needed for the multibyte string. More... | |
int | tuklib_mbstr_fw (const char *str, int columns_min) |
Get the field width for printf() e.g. to align table columns. More... | |
Utility functions for handling multibyte strings.
If not enough multibyte string support is available in the C library, these functions keep working with the assumption that all strings are in a single-byte character set without combining characters, e.g. US-ASCII or ISO-8859-*.
Definition in file tuklib_mbstr.h.
#define tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw) |
Definition at line 45 of file tuklib_mbstr.h.
#define tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width) |
Definition at line 24 of file tuklib_mbstr.h.
Get the field width for printf() e.g. to align table columns.
Printing simple tables to a terminal can be done using the field field feature in the printf() format string, but it works only with single-byte character sets. To do the same with multibyte strings, tuklib_mbstr_fw() can be used to calculate appropriate field width.
The behavior of this function is undefined, if
Definition at line 17 of file tuklib_mbstr_fw.c.
References len, cmd_descs_generate::str, tuklib_mbstr_width, and width.
Get the number of columns needed for the multibyte string.
This is somewhat similar to wcswidth() but works on multibyte strings.
str | String whose width is to be calculated. If the current locale uses a multibyte character set that has shift states, the string must begin and end in the initial shift state. |
bytes | If this is not NULL, *bytes is set to the value returned by strlen(str) (even if an error occurs when calculating the width). |
Definition at line 22 of file tuklib_mbstr_width.c.
References bytes, i, len, memset(), NULL, cmd_descs_generate::str, and width.