W3cubDocs

/Dart 2

operator [] method

String operator [] (int index)

Gets the character (as a single-code-unit String) at the given index.

The returned string represents exactly one UTF-16 code unit, which may be half of a surrogate pair. A single member of a surrogate pair is an invalid UTF-16 string:

var clef = '\u{1D11E}';
// These represent invalid UTF-16 strings.
clef[0].codeUnits;      // [0xD834]
clef[1].codeUnits;      // [0xDD1E]

This method is equivalent to new String.fromCharCode(this.codeUnitAt(index)).

Implementation

String operator [](int index);

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-core/String/operator_get.html