string totitle

Gives a string with its first character in title case and the rest in lowercase.

string totitle STRING ?FIRST? ?LAST?

Description

Gives STRING with its first character in title case and each other character in lowercase. Title case is uppercase for most letters, and the title form for a letter such as dž. The command changes only the first character of the whole string, and the first letter of each other word goes to lowercase.

With FIRST and LAST it changes only that range: the character at FIRST goes to title case and the rest of the range to lowercase.

Arguments

ArgumentTypeDefaultDescription
STRINGstringrequiredThe text to change.
FIRSTindex0The index of the first character to change.
LASTindexFIRST, or end with no FIRSTThe index of the last character to change.

Returns

The new string.

Examples

% string totitle "hELLO wORLD"
Hello world

% string totitle "hello world" 6 end
hello World

% string totitle džemal
Džemal

Errors

% string totitle abc x
bad index "x": must be integer?[+-]integer? or end?[+-]integer?
-errorcode NONE

% string totitle
wrong # args: should be "string totitle string ?first? ?last?"
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also