Macros | Functions
charset.c File Reference
#include <assert.h>
#include <string.h>
#include <wctype.h>
#include <wchar.h>
#include <inttypes.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/func_attr.h"
#include "nvim/indent.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/misc1.h"
#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/path.h"
#include "nvim/cursor.h"

Macros

#define SET_CHARTAB(buf, c)   (buf)->b_chartab[(unsigned)(c) >> 6] |= (1ull << ((c) & 0x3f))
 
#define RESET_CHARTAB(buf, c)   (buf)->b_chartab[(unsigned)(c) >> 6] &= ~(1ull << ((c) & 0x3f))
 
#define GET_CHARTAB_TAB(chartab, c)   ((chartab)[(unsigned)(c) >> 6] & (1ull << ((c) & 0x3f)))
 
#define GET_CHARTAB(buf, c)   GET_CHARTAB_TAB((buf)->b_chartab, c)
 
#define CT_CELL_MASK   0x07
 mask: nr of display cells (1, 2 or 4) More...
 
#define CT_PRINT_CHAR   0x10
 flag: set for printable chars More...
 
#define CT_ID_CHAR   0x20
 flag: set for ID chars More...
 
#define CT_FNAME_CHAR   0x40
 flag: set for file name chars More...
 
#define GA_CHAR(i)   ((char_u *)ga.ga_data)[i]
 
#define GA_PTR(i)   ((char_u *)ga.ga_data + i)
 
#define STR_CHAR(i)   (buf == NULL ? GA_CHAR(i) : buf[i])
 
#define STR_PTR(i)   (buf == NULL ? GA_PTR(i) : buf + i)
 
#define RET_WIN_BUF_CHARTABSIZE(wp, buf, p, col)
 
#define STRING_ENDED(ptr)   (!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen))
 
#define PARSE_NUMBER(base, cond, conv)
 

Functions

int init_chartab (void)
 
int buf_init_chartab (buf_T *buf, int global)
 
void trans_characters (char_u *buf, int bufsize)
 
size_t transstr_len (const char *const s) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
 
size_t transstr_buf (const char *const s, char *const buf, const size_t len) FUNC_ATTR_NONNULL_ALL
 
char * transstr (const char *const s) FUNC_ATTR_NONNULL_RET
 
char_ustr_foldcase (char_u *str, int orglen, char_u *buf, int buflen) FUNC_ATTR_NONNULL_RET
 
char_utranschar (int c)
 
char_utranschar_byte (const int c) FUNC_ATTR_WARN_UNUSED_RESULT
 
void transchar_nonprint (char_u *buf, int c)
 
size_t transchar_hex (char *const buf, const int c) FUNC_ATTR_NONNULL_ALL
 
int byte2cells (int b)
 
int char2cells (int c)
 
int ptr2cells (const char_u *p)
 
int vim_strsize (char_u *s)
 
int vim_strnsize (char_u *s, int len)
 
int chartabsize (char_u *p, colnr_T col)
 
int linetabsize (char_u *s)
 
int linetabsize_col (int startcol, char_u *s)
 
unsigned int win_linetabsize (win_T *wp, char_u *line, colnr_T len)
 
bool vim_isIDc (int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool vim_iswordc (const int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool vim_iswordc_tab (const int c, const uint64_t *const chartab) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
bool vim_iswordc_buf (const int c, buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(2)
 
bool vim_iswordp (const char_u *const p) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
bool vim_iswordp_buf (const char_u *const p, buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
bool vim_isfilec (int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool vim_isfilec_or_wc (int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool vim_isprintc (int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool vim_isprintc_strict (int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
int lbr_chartabsize (char_u *line, unsigned char *s, colnr_T col)
 
int lbr_chartabsize_adv (char_u *line, char_u **s, colnr_T col)
 
int win_lbr_chartabsize (win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp)
 
bool in_win_border (win_T *wp, colnr_T vcol) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1)
 
void getvcol (win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end)
 
colnr_T getvcol_nolist (pos_T *posp)
 
void getvvcol (win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end)
 
void getvcols (win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, colnr_T *right)
 
char_uskipwhite (const char_u *q) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
 
intptr_t getwhitecols_curline (void)
 
intptr_t getwhitecols (const char_u *p)
 
char_uskipdigits (const char_u *q) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
 
const char * skipbin (const char *q) FUNC_ATTR_PURE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
 
char_uskiphex (char_u *q)
 
char_uskiptodigit (char_u *q)
 
const char * skiptobin (const char *q) FUNC_ATTR_PURE FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
 
char_uskiptohex (char_u *q)
 
char_uskiptowhite (const char_u *p)
 
char_uskiptowhite_esc (char_u *p)
 
bool try_getdigits (char_u **pp, intmax_t *nr)
 
intmax_t getdigits (char_u **pp, bool strict, intmax_t def)
 
int getdigits_int (char_u **pp, bool strict, int def)
 
long getdigits_long (char_u **pp, bool strict, long def)
 
bool vim_isblankline (char_u *lbuf)
 
void vim_str2nr (const char_u *const start, int *const prep, int *const len, const int what, varnumber_T *const nptr, uvarnumber_T *const unptr, const int maxlen) FUNC_ATTR_NONNULL_ARG(1)
 
int hex2nr (int c)
 
bool rem_backslash (const char_u *str) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
void backslash_halve (char_u *p)
 
char_ubackslash_halve_save (const char_u *p) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
 

Detailed Description

Code related to character sets.

Macro Definition Documentation

#define CT_CELL_MASK   0x07

mask: nr of display cells (1, 2 or 4)

#define CT_FNAME_CHAR   0x40

flag: set for file name chars

#define CT_ID_CHAR   0x20

flag: set for ID chars

#define CT_PRINT_CHAR   0x10

flag: set for printable chars

#define GA_CHAR (   i)    ((char_u *)ga.ga_data)[i]
#define GA_PTR (   i)    ((char_u *)ga.ga_data + i)
#define GET_CHARTAB (   buf,
 
)    GET_CHARTAB_TAB((buf)->b_chartab, c)
#define GET_CHARTAB_TAB (   chartab,
 
)    ((chartab)[(unsigned)(c) >> 6] & (1ull << ((c) & 0x3f)))
#define PARSE_NUMBER (   base,
  cond,
  conv 
)
Value:
do { \
while (!STRING_ENDED(ptr) && (cond)) { \
const uvarnumber_T digit = (uvarnumber_T)(conv); \
/* avoid ubsan error for overflow */ \
if (un < UVARNUMBER_MAX / base \
|| (un == UVARNUMBER_MAX / base \
&& (base != 10 || digit <= UVARNUMBER_MAX % 10))) { \
un = base * un + digit; \
} else { \
} \
ptr++; \
} \
} while (0)
if(len)
Definition: encode.c:222
#define STRING_ENDED(ptr)
uint64_t uvarnumber_T
Definition: typval.h:27
#define UVARNUMBER_MAX
Definition: typval.h:56
while(argv_clear > 0)
Definition: eval.c:6574
#define RESET_CHARTAB (   buf,
 
)    (buf)->b_chartab[(unsigned)(c) >> 6] &= ~(1ull << ((c) & 0x3f))
#define RET_WIN_BUF_CHARTABSIZE (   wp,
  buf,
  p,
  col 
)
Value:
if (*(p) == TAB && (!(wp)->w_p_list || wp->w_p_lcs_chars.tab1)) { \
const int ts = (int)(buf)->b_p_ts; \
return (ts - (int)(col % ts)); \
} else { \
}
#define w_p_list
Definition: buffer_defs.h:200
int ptr2cells(const char_u *p)
Definition: charset.c:685
#define TAB
Definition: ascii.h:22
char *const buf
Definition: encode.c:231
return
Definition: eval.c:15624
char_u * p
Definition: eval.c:2157

Return the number of characters 'c' will take on the screen, taking into account the size of a tab. Use a define to make it fast, this is used very often!!! Also see getvcol() below.

Parameters
p
col
Returns
Number of characters.
#define SET_CHARTAB (   buf,
 
)    (buf)->b_chartab[(unsigned)(c) >> 6] |= (1ull << ((c) & 0x3f))
#define STR_CHAR (   i)    (buf == NULL ? GA_CHAR(i) : buf[i])
#define STR_PTR (   i)    (buf == NULL ? GA_PTR(i) : buf + i)
#define STRING_ENDED (   ptr)    (!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen))

Function Documentation

void backslash_halve ( char_u p)

Halve the number of backslashes in a file name argument.

Parameters
p
char_u* backslash_halve_save ( const char_u p)

backslash_halve() plus save the result in allocated memory.

Parameters
p
Returns
String with the number of backslashes halved.
int buf_init_chartab ( buf_T buf,
int  global 
)

Helper for init_chartab

Parameters
globalfalse: only set buf->b_chartab[]
Returns
FAIL if 'iskeyword', 'isident', 'isfname' or 'isprint' option has an error, OK otherwise.
int byte2cells ( int  b)

Return number of display cells occupied by byte "b".

Caller must make sure 0 <= b <= 255. For multi-byte mode "b" must be the first byte of a character. A TAB is counted as two cells: "^I". This will return 0 for bytes >= 0x80, because the number of cells depends on further bytes in UTF-8.

Parameters
bNumber of display cells.
int char2cells ( int  c)

Return number of display cells occupied by character "c".

"c" can be a special key (negative number) in which case 3 or 4 is returned. A TAB is counted as two cells: "^I" or four: "<09>".

Parameters
c
Returns
Number of display cells.
int chartabsize ( char_u p,
colnr_T  col 
)
intmax_t getdigits ( char_u **  pp,
bool  strict,
intmax_t  def 
)

Gets a number from a string and skips over it.

Parameters
[out]ppPointer to a pointer to char_u. It will be advanced past the read number.
strictAbort on overflow.
defDefault value, if parsing fails or overflow occurs.
Returns
Number read from the string, or def on parse failure or overflow.
int getdigits_int ( char_u **  pp,
bool  strict,
int  def 
)

Gets an int number from a string.

See also
getdigits
long getdigits_long ( char_u **  pp,
bool  strict,
long  def 
)

Gets a long number from a string.

See also
getdigits
void getvcol ( win_T wp,
pos_T pos,
colnr_T start,
colnr_T cursor,
colnr_T end 
)

Get virtual column number of pos. start: on the first position of this character (TAB, ctrl) cursor: where the cursor is on this character (first char, except for TAB) end: on the last position of this character (TAB, ctrl)

This is used very often, keep it fast!

Parameters
wp
pos
start
cursor
end
colnr_T getvcol_nolist ( pos_T posp)

Get virtual cursor column in the current window, pretending 'list' is off.

Parameters
pospThe virtual cursor column.
void getvcols ( win_T wp,
pos_T pos1,
pos_T pos2,
colnr_T left,
colnr_T right 
)

Get the leftmost and rightmost virtual column of pos1 and pos2. Used for Visual block mode.

Parameters
wp
pos1
pos2
left
right
void getvvcol ( win_T wp,
pos_T pos,
colnr_T start,
colnr_T cursor,
colnr_T end 
)

Get virtual column in virtual mode.

Parameters
wp
pos
start
cursor
end
intptr_t getwhitecols ( const char_u p)
intptr_t getwhitecols_curline ( void  )
int hex2nr ( int  c)

Return the value of a single hex character. Only valid when the argument is '0' - '9', 'A' - 'F' or 'a' - 'f'.

Parameters
c
Returns
The value of the hex character.
bool in_win_border ( win_T wp,
colnr_T  vcol 
)

Check that virtual column "vcol" is in the rightmost column of window "wp".

Parameters
wpwindow
vcolcolumn number
int init_chartab ( void  )

Fill g_chartab[]. Also fills curbuf->b_chartab[] with flags for keyword characters for current buffer.

Depends on the option settings 'iskeyword', 'isident', 'isfname', 'isprint' and 'encoding'.

The index in g_chartab[] is the character when first byte is up to 0x80, if the first byte is 0x80 and above it depends on further bytes.

The contents of g_chartab[]:

  • The lower two bits, masked by CT_CELL_MASK, give the number of display cells the character occupies (1 or 2). Not valid for UTF-8 above 0x80.
  • CT_PRINT_CHAR bit is set when the character is printable (no need to translate the character before displaying it). Note that only DBCS characters can have 2 display cells and still be printable.
  • CT_FNAME_CHAR bit is set when the character can be in a file name.
  • CT_ID_CHAR bit is set when the character can be in an identifier.
Returns
FAIL if 'iskeyword', 'isident', 'isfname' or 'isprint' option has an error, OK otherwise.
int lbr_chartabsize ( char_u line,
unsigned char *  s,
colnr_T  col 
)

like chartabsize(), but also check for line breaks on the screen

Parameters
line
s
col
Returns
The number of characters taken up on the screen.
int lbr_chartabsize_adv ( char_u line,
char_u **  s,
colnr_T  col 
)

Call lbr_chartabsize() and advance the pointer.

Parameters
line
s
col
Returns
The number of characters take up on the screen.
int linetabsize ( char_u s)

Return the number of characters the string 's' will take on the screen, taking into account the size of a tab.

Parameters
s
Returns
Number of characters the string will take on the screen.
int linetabsize_col ( int  startcol,
char_u s 
)

Like linetabsize(), but starting at column "startcol".

Parameters
startcol
s
Returns
Number of characters the string will take on the screen.
int ptr2cells ( const char_u p)

Return number of display cells occupied by character at "*p". A TAB is counted as two cells: "^I" or four: "<09>".

Parameters
p
Returns
number of display cells.
bool rem_backslash ( const char_u str)

Check that "str" starts with a backslash that should be removed. For Windows this is only done when the character after the backslash is not a normal file name character. '$' is a valid file name character, we don't remove the backslash before it. This means it is not possible to use an environment variable after a backslash. "C:\$VIM\doc" is taken literally, only "$VIM\doc" works. Although "\ name" is valid, the backslash in "Program\ files" must be removed. Assume a file name doesn't start with a space. For multi-byte names, never remove a backslash before a non-ascii character, assume that all multi-byte characters are valid file name characters.

Parameters
strfile path string to check
const char* skipbin ( const char *  q)

skip over binary digits

Parameters
qpointer to string
Returns
Pointer to the character after the skipped digits.
char_u* skipdigits ( const char_u q)

Skip over digits

Parameters
[in]qString to skip digits in.
Returns
Pointer to the character after the skipped digits.
char_u* skiphex ( char_u q)

skip over digits and hex characters

Parameters
q
Returns
Pointer to the character after the skipped digits and hex characters.
const char* skiptobin ( const char *  q)

skip to binary character (or NUL after the string)

Parameters
qpointer to string
Returns
Pointer to the binary character or (NUL after the string).
char_u* skiptodigit ( char_u q)

skip to digit (or NUL after the string)

Parameters
q
Returns
Pointer to the digit or (NUL after the string).
char_u* skiptohex ( char_u q)

skip to hex character (or NUL after the string)

Parameters
q
Returns
Pointer to the hex character or (NUL after the string).
char_u* skiptowhite ( const char_u p)

Skip over text until ' ' or '' or NUL

Parameters
[in]pText to skip over.
Returns
Pointer to the next whitespace or NUL character.
char_u* skiptowhite_esc ( char_u p)

skiptowhite_esc: Like skiptowhite(), but also skip escaped chars

Parameters
p
Returns
Pointer to the next whitespace character.
char_u* skipwhite ( const char_u q)

skipwhite: skip over ' ' and ''.

Parameters
[in]qString to skip in.
Returns
Pointer to character after the skipped whitespace.
char_u* str_foldcase ( char_u str,
int  orglen,
char_u buf,
int  buflen 
)

Convert the string "str[orglen]" to do ignore-case comparing. Use the current locale.

When "buf" is NULL, return an allocated string. Otherwise, put the result in buf, limited by buflen, and return buf.

void trans_characters ( char_u buf,
int  bufsize 
)

Translate any special characters in buf[bufsize] in-place.

The result is a string with only printable characters, but if there is not enough room, not all characters will be translated.

Parameters
buf
bufsize
char_u* transchar ( int  c)

Translate a character into a printable one, leaving printable ASCII intact

All unicode characters are considered non-printable in this function.

Parameters
[in]cCharacter to translate.
Returns
translated character into a static buffer.
char_u* transchar_byte ( const int  c)

Like transchar(), but called with a byte instead of a character

Checks for an illegal UTF-8 byte.

Parameters
[in]cByte to translate.
Returns
pointer to translated character in transchar_buf.
size_t transchar_hex ( char *const  buf,
const int  c 
)

Convert a non-printable character to hex C string like "<FFFF>"

Parameters
[out]bufBuffer to store result in.
[in]cCharacter to convert.
Returns
Number of bytes stored in buffer, excluding trailing NUL byte.
void transchar_nonprint ( char_u buf,
int  c 
)

Convert non-printable characters to 2..4 printable ones

Warning
Does not work for multi-byte characters, c must be <= 255.
Parameters
[out]bufBuffer to store result in, must be able to hold at least 5 bytes (conversion result + NUL).
[in]cCharacter to convert. NUL is assumed to be NL according to :h NL-used-for-NUL.
char* transstr ( const char *const  s)

Copy string and replace special characters with printable characters

Works like strtrans() does, used for that and in some other places.

Parameters
[in]sString to replace characters from.
Returns
[allocated] translated string
size_t transstr_buf ( const char *const  s,
char *const  buf,
const size_t  len 
)

Replace special characters with printable ones

Parameters
[in]sString to replace characters from.
[out]bufBuffer to which result should be saved.
[in]lenBuffer length. Resulting string may not occupy more then len - 1 bytes (one for trailing NUL byte).
Returns
length of the resulting string, without the NUL byte.
size_t transstr_len ( const char *const  s)

Find length of a string capable of holding s with all specials replaced

Assumes replacing special characters with printable ones just like strtrans() does.

Parameters
[in]sString to check.
Returns
number of bytes needed to hold a translation of s, NUL byte not included.
bool try_getdigits ( char_u **  pp,
intmax_t *  nr 
)

Gets a number from a string and skips over it, signalling overflow.

Parameters
[out]ppA pointer to a pointer to char_u. It will be advanced past the read number.
[out]nrNumber read from the string.
Returns
true on success, false on error/overflow
bool vim_isblankline ( char_u lbuf)

Check that "lbuf" is empty or only contains blanks.

Parameters
lbufline buffer to check
bool vim_isfilec ( int  c)

Check that "c" is a valid file-name character. Assume characters above 0x100 are valid (multi-byte).

Parameters
ccharacter to check
bool vim_isfilec_or_wc ( int  c)

Check that "c" is a valid file-name character or a wildcard character Assume characters above 0x100 are valid (multi-byte). Explicitly interpret ']' as a wildcard character as path_has_wildcard("]") returns false.

Parameters
ccharacter to check
bool vim_isIDc ( int  c)

Check that "c" is a normal identifier character: Letters and characters from the 'isident' option.

Parameters
ccharacter to check
bool vim_isprintc ( int  c)

Check that "c" is a printable character. Assume characters above 0x100 are printable for double-byte encodings.

Parameters
ccharacter to check
bool vim_isprintc_strict ( int  c)

Strict version of vim_isprintc(c), don't return true if "c" is the head byte of a double-byte character.

Parameters
ccharacter to check
Returns
true if "c" is a printable character.
bool vim_iswordc ( const int  c)

Check that "c" is a keyword character: Letters and characters from 'iskeyword' option for the current buffer. For multi-byte characters mb_get_class() is used (builtin rules).

Parameters
ccharacter to check
bool vim_iswordc_buf ( const int  c,
buf_T *const  buf 
)

Check that "c" is a keyword character: Letters and characters from 'iskeyword' option for given buffer. For multi-byte characters mb_get_class() is used (builtin rules).

Parameters
ccharacter to check
bufbuffer whose keywords to use
bool vim_iswordc_tab ( const int  c,
const uint64_t *const  chartab 
)

Check that "c" is a keyword character Letters and characters from 'iskeyword' option for given buffer. For multi-byte characters mb_get_class() is used (builtin rules).

Parameters
[in]cCharacter to check.
[in]chartabBuffer chartab.
bool vim_iswordp ( const char_u *const  p)

Just like vim_iswordc() but uses a pointer to the (multi-byte) character.

Parameters
ppointer to the multi-byte character
Returns
true if "p" points to a keyword character.
bool vim_iswordp_buf ( const char_u *const  p,
buf_T *const  buf 
)

Just like vim_iswordc_buf() but uses a pointer to the (multi-byte) character.

Parameters
ppointer to the multi-byte character
bufbuffer whose keywords to use
Returns
true if "p" points to a keyword character.
void vim_str2nr ( const char_u *const  start,
int *const  prep,
int *const  len,
const int  what,
varnumber_T *const  nptr,
uvarnumber_T *const  unptr,
const int  maxlen 
)

Convert a string into a long and/or unsigned long, taking care of hexadecimal, octal and binary numbers. Accepts a '-' sign. If "prep" is not NULL, returns a flag to indicate the type of the number: 0 decimal '0' octal 'B' bin 'b' bin 'X' hex 'x' hex If "len" is not NULL, the length of the number in characters is returned. If "nptr" is not NULL, the signed result is returned in it. If "unptr" is not NULL, the unsigned result is returned in it. If "what" contains STR2NR_BIN recognize binary numbers. If "what" contains STR2NR_OCT recognize octal numbers. If "what" contains STR2NR_HEX recognize hex numbers. If "what" contains STR2NR_FORCE always assume bin/oct/hex. If maxlen > 0, check at a maximum maxlen chars.

Parameters
start
prepReturns guessed type of number 0 = decimal, 'x' or 'X' is hexadecimal, '0' = octal, 'b' or 'B' is binary. When using STR2NR_FORCE is always zero.
lenReturns the detected length of number.
whatRecognizes what number passed,
See also
ChStr2NrFlags.
Parameters
nptrReturns the signed result.
unptrReturns the unsigned result.
maxlenMax length of string to check.
int vim_strnsize ( char_u s,
int  len 
)

Return the number of character cells string "s[len]" will take on the screen, counting TABs as two characters: "^I".

's' must be non-null.

Parameters
s
len
Returns
Number of character cells.
int vim_strsize ( char_u s)

Return the number of character cells string "s" will take on the screen, counting TABs as two characters: "^I".

's' must be non-null.

Parameters
s
Returns
number of character cells.
int win_lbr_chartabsize ( win_T wp,
char_u line,
char_u s,
colnr_T  col,
int *  headp 
)

This function is used very often, keep it fast!!!!

If "headp" not NULL, set *headp to the size of what we for 'showbreak' string at start of line. Warning: *headp is only set if it's a non-zero value, init to 0 before calling.

Parameters
wp
line
s
col
headp
Returns
The number of characters taken up on the screen.
unsigned int win_linetabsize ( win_T wp,
char_u line,
colnr_T  len 
)

Like linetabsize(), but for a given window instead of the current one.

Parameters
wp
line
len
Returns
Number of characters the string will take on the screen.