Home

tcslen

tcslen is a function provided by the Windows C run-time library as part of the generic-text mapping in tchar.h. It computes the length of a null-terminated string consisting of TCHAR elements, returning the number of characters before the terminating null character.

TCHAR is a character type that can represent either a single-byte char (in ANSI builds) or a

The typical signature is size_t tcslen(const TCHAR* s); The function does not include the terminating null in

Usage typically requires including <tchar.h> and using TCHAR-based strings, which can be declared with the _T

Notes: tcslen counts characters, not bytes, and assumes a properly null-terminated string. It is not a function

wide
character
wchar_t
(in
Unicode
builds).
The
tcslen
function
therefore
adapts
to
the
active
character
width:
in
ANSI
builds
it
maps
to
strlen,
while
in
Unicode
builds
it
maps
to
wcslen.
Depending
on
the
header
and
compiler,
the
symbol
may
appear
as
tcslen
or
as
_tcslen,
with
tcslen
often
acting
as
a
portable
alias
to
the
underlying
function.
the
count
and
returns
the
length
of
the
string
in
TCHAR
units.
It
is
a
read-only
operation
and
does
not
modify
the
input
string.
or
_TEXT
macros
to
remain
portable
across
ANSI
and
Unicode
builds.
For
example,
const
TCHAR*
s
=
_T("example");
size_t
len
=
tcslen(s);
for
raw
buffers
without
a
terminating
null,
and
its
meaning
varies
with
the
TCHAR
mapping
used
by
the
project.
See
also
strlen,
wcslen,
and
the
tchar.h
header
for
related
generic-text
utilities.