echo "words words words ⚑"
echo """

</html> """

proc re(s: string): string = s

echo r".""."
echo re"\b[a-z]++\b"
$ nim c -r strings.nim
words words words ⚑


There are several types of string literals:

Strings are null-terminated, so that cstring("foo") requires zero copying. However, you should be careful that the lifetime of the cstring does not exceed the lifetime of the string it is based upon.

Strings can also almost be thought of as seq[char] with respect to assignment semantics. See seqs

A note about unicode

Unicode symbols are allowed in strings, but are not treated in any special way, so if you want count glyphs or uppercase unicode symbols, you must use the unicode module.

Strings are generally considered to be encoded as UTF-8, so because of unicode’s backwards compatibility, can be treated exactly as ASCII, with all values above 127 ignored.