Dart String runes
Syntax & Examples

Syntax of String.runes

The syntax of String.runes property is:

 Runes runes 

This runes property of String returns An Iterable of Unicode code-points of this string.

Return Type

String.runes returns value of type Runes.



✐ Examples

1 Access the runes of a string

In this example,

  1. We create a string str with the value 'Hello'.
  2. We then access the runes property of the string.
  3. This property returns an Iterable of Unicode code-points of the string.
  4. We print the result to standard output.

Dart Program

void main() {
  String str = 'Hello';
  Iterable<int> strRunes = str.runes;
  print('Runes of $str: $strRunes');
}

Output

Runes of Hello: (72, 101, 108, 108, 111)

2 Access the runes of another string

In this example,

  1. We create a string str with the value 'ABCDEF'.
  2. We then access the runes property of the string.
  3. This property returns an Iterable of Unicode code-points of the string.
  4. We print the result to standard output.

Dart Program

void main() {
  String str = 'ABCDEF';
  Iterable<int> strRunes = str.runes;
  print('Runes of $str: $strRunes');
}

Output

Runes of ABCDEF: (65, 66, 67, 68, 69, 70)

3 Access the runes of a longer string

In this example,

  1. We create a string str with the value 'Lorem ipsum'.
  2. We then access the runes property of the string.
  3. This property returns an Iterable of Unicode code-points of the string.
  4. We print the result to standard output.

Dart Program

void main() {
  String str = 'Lorem ipsum';
  Iterable<int> strRunes = str.runes;
  print('Runes of $str: $strRunes');
}

Output

Runes of Lorem ipsum: (76, 111, 114, 101, 109, 32, 105, 112, 115, 117, 109)

Summary

In this Dart tutorial, we learned about runes property of String: the syntax and few working examples with output and detailed explanation for each example.