Function [nline,maxwidth] = textblocksize(s)
[nline,maxwidth] = textblocksize(s,opt)
returns the number of lines and the maximal width (i.e.
maximal number of characters) of the lines in the given
string.
The input argument s is a character row vector or a
cell-array of character row vectors. The output arguments
nline and maxwidth are scalars in the former case, and
matrices of the same sizes as s in the latter case.
The optional input arugment opt is a struct or a row
cell-array of key-value pairs. Below, settings are
indicated by opt as a struct, and the default value of
each field are given too:
opt.linedelim = "\n";
opt.linedelim contains the line delimiter, i.e. the
character by which lines are separated within a
string.
The function takes care of the utf-8 encoding of strings,
and accounts for the real number of characters instead of
simply counting the number of bytes in a string.
The function internally calls the following non-standard
m-files:
-- kvpairs2struct.m
-- unicodelength.m
(c) 2026 fabien van mook
2026.08.20 release of this file within package "fvm-textblock" under GNU GPLv3+