Strings
Strings in Run are UTF-8 encoded byte sequences. The string type is string.
package main
use "fmt"
pub fun main() { greeting := "Hello, Run!" fmt.println(greeting)}Iteration
Section titled “Iteration”Iterating over a string yields characters (Unicode code points) by default.
Character iteration (default)
Section titled “Character iteration (default)”Ranging over a string directly gives you one character per iteration. This handles multi-byte UTF-8 sequences correctly.
for ch in greeting { fmt.println(ch)}Byte iteration
Section titled “Byte iteration”Use .bytes to iterate over the raw bytes of a string instead.
for b in greeting.bytes { fmt.println(b)}Byte iteration is faster but does not respect character boundaries — a multi-byte character will appear as multiple separate bytes.