Softanza
StartFrançais
Softanza
Reference · stzString

NumberOfChars()

The length of the string in characters (Unicode codepoints).

also: length string length length of the string size how long count characters number of letters

also written: Length

Basic examples (2)

Softanza
ostr = new stzString("s㊱m")
? ostr.NumberOfChars()
? ostr[2]
Output
3
㊱

run on 2026-10-02 04:22 inside the library at commit 0e72e2e2c; taken from 116_numberofchars.ring(opens in a new tab)

Softanza
# NumberOfChars('softanza') is 8
? Q("softanza").NumberOfChars()
# NumberOfChars('héllo') is 5 (not byte count)
? Q("héllo").NumberOfChars()
Output
8
5

run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from 00_string_narrated.ring(opens in a new tab)

Scope (8)

Softanza
# M is one char
? Q("M").NumberOfChars()
# the koala too
? Q("🐨").NumberOfChars()
# but four bytes
? len("🐨")
Output
1
1
4

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 859_numberofchars.ring(opens in a new tab)

Softanza
# CharsW with a { Q(@char).isLetter() } block keeps just the letters
? @@( Q("~~H/U/S/S/E/I/N~~").CharsW('{ Q(@char).isLetter() }') )
# the plain-DSL form isLetter(@char) is equivalent
? @@( Q("~~H/U/S/S/E/I/N~~").CharsW('isLetter(@char)') )
# NumberOfCharsW counts the matches
? Q("~~H/U/S/S/E/I/N~~").NumberOfCharsW('{ Q(@char).isLetter() }')
Output
[ "H", "U", "S", "S", "E", "I", "N" ]
[ "H", "U", "S", "S", "E", "I", "N" ]
7

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 713_charsw.ring(opens in a new tab)

Softanza
oAB  = new stzString("ab")
big  = new stzString( oAB.Repeated(1000000) )
oRev = new stzString( big.Reversed() )
# Reversed keeps full length
? oRev.NumberOfChars()
# Reversed head is 'ba'
? oRev.Section(1, 2)
Output
2000000
ba

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 999_engine_string_millions_narrated.ring(opens in a new tab)

Softanza
o1 = new stzString("abc" + nl + "de" + nl + "f")
# NumberOfChars counts every char incl. newlines
? o1.NumberOfChars()
# NumberOfLines is 3
? o1.NumberOfLines()
# SplitQ(NL).NumberOfItems agrees
? o1.SplitQ(nl).NumberOfItems()
Output
8
3
3

run on 2026-10-02 04:23 inside the library at commit 0e72e2e2c; taken from 232_numberofchars.ring(opens in a new tab)

Softanza
? StzCharQ(dec("0x10481")).Content()
? Q("Schöne Grüße").Length() # means "Kind Regards" in german
? StzUnicodeDataQ().CharByName("OSMANYA LETTER BA")
? StzCharQ("ҁ").Name()
? StzCharQ("𐒁").Content()
? Q("𐒁").CharName()
? StzCharQ("OSMANYA LETTER BA").Content()
Output
𐒁
12
𐒁
CYRILLIC SMALL LETTER KOPPA
𐒁
OSMANYA LETTER BA
𐒁

run on 2026-10-02 04:22 inside the library at commit 0e72e2e2c; taken from 07_todo_logical_errors.ring(opens in a new tab)

Softanza
oAB  = new stzString("ab")
big  = new stzString( oAB.Repeated(1000000) )
# NumberOfChars is 2,000,000
? big.NumberOfChars()
# Contains 'ab' is TRUE
? big.Contains("ab")
# FindFirst 'ab' is 1
? big.FindFirst("ab")
# FindLast 'ab' is 1,999,999
? big.FindLast("ab")
Output
2000000
1
1
1999999

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 999_engine_string_millions_narrated.ring(opens in a new tab)

Softanza
oAB  = new stzString("ab")
big  = new stzString( oAB.Repeated(1000000) )
oE = new stzString("😀🎉")
e  = new stzString( oE.Repeated(50000) )
# NumberOfChars is 100,000 codepoints
? e.NumberOfChars()
# NumberOfOccurrences('😀') is 50,000
? e.NumberOfOccurrences("😀")
# Reversed keeps 100,000 codepoints
? StzLen(e.Reversed())
Output
100000
50000
100000

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 999_engine_string_millions_narrated.ring(opens in a new tab)

Softanza
oAB  = new stzString("ab")
big  = new stzString( oAB.Repeated(1000000) )
oUp = new stzString( big.Uppercased() )
# Uppercased keeps full 2,000,000 length
? oUp.NumberOfChars()
# Uppercased head is 'ABAB'
? oUp.Section(1, 4)
# Uppercased has 1,000,000 'A'
? oUp.NumberOfOccurrences("A")
# Uppercased has zero 'a'
? oUp.NumberOfOccurrences("a")
Output
2000000
ABAB
1000000
0

run on 2026-10-02 04:24 inside the library at commit 0e72e2e2c; taken from 999_engine_string_millions_narrated.ring(opens in a new tab)

and 1 more in the tests

The extensions of this method

Each extension, and whether it exists for this method; an extension that exists combines with the others (FindSTCS).

Extension
Exists
What it adds · The names
Q
yes
does what the method does, then returns the object, so the call can be chained · LengthQ
QQ
no
chains on the next, more specific type of object (the Q ladder)
QQQ
no
chains on the most specific type of object (the Q ladder)
QRT
no
returns the result as an object of the requested type
CS
no
takes a case-sensitivity flag
ST
no
takes the position to start from (StartingAt)
IB
no
takes bounds that are included (IncludingBounds)
XT
no
the extended form: more parameters than the base method
XTT
no
yet another extension: a further extended form, after XT
Z
no
includes the position in what it returns
ZZ
no
returns positions as sections, [start, end]
W
yes
selects by a condition · NumberOfCharsW
WF
no
selects by a condition, with the expressive keywords (@NextItem, @PreviousItem...)
D
no
takes a direction, forward or backward (Directional)
F
no
takes a function (the condition or the update is given as a function); the forms document also uses F for the future form, which defers the action
Many
no
works on a collection of items instead of one (the plural form)
Except
no
takes exceptions, what to leave out (the exceptional form)
U
no
returns the result without duplication

Every example is a test file of the library, run inside the library for this page; only those whose output kept every promise their file wrote are shown.

See also