Logo

Programming-Idioms

History of Idiom 169 > diff from v69 to v70

Edit summary for version 70 by thethanlaw:
New Ada implementation by user [thethanlaw]

Version 69

2019-09-27, 23:09:30

Version 70

2019-09-28, 03:35:34

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Code
s : String := "Hello World";
n : Integer : s'Length;
Comments bubble
Easy! Just use the 'Length attribute of the String type.

Note that strings are not variable length.
Doc URL
https://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-3-6-3.html