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)
ostr = new stzString("s㊱m")
? ostr.NumberOfChars()
? ostr[2]3 ㊱
run on 2026-10-02 04:22 inside the library at commit 0e72e2e2c; taken from 116_numberofchars.ring(opens in a new tab)
# NumberOfChars('softanza') is 8
? Q("softanza").NumberOfChars()
# NumberOfChars('héllo') is 5 (not byte count)
? Q("héllo").NumberOfChars()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)
# M is one char
? Q("M").NumberOfChars()
# the koala too
? Q("🐨").NumberOfChars()
# but four bytes
? len("🐨")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)
# 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() }')[ "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)
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)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)
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()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)
? 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()𐒁 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)
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")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)
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())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)
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")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).
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
- The class stzString
- The area's reference: String
- The other methods in these examples: stzString.CharName · stzString.Chars · stzString.Contains · stzString.Count · stzString.FindFirst · stzString.FindLast · stzString.NumberOfLines · stzString.Reversed · stzString.Section · stzString.Split · stzUnicodeData.CharByName

