String.byCodePoint

  1. ByCodePoint!char byCodePoint()
  2. ByCodePoint!(const char) byCodePoint()
    struct String
    const @nogc nothrow pure @trusted
    ByCodePoint!(const char)
    byCodePoint
    ()

Return Value

Type: ByCodePoint!(const char)

Forward range that iterates over the string by code points.

Examples

auto s = String("Мне есть, что спеть, представ перед Всевышним.");
auto cp = s.byCodePoint();
assert(cp.front == 'М');
cp.popFront();
assert(cp.front == 'н');

s = String("€");
cp = s.byCodePoint();
assert(cp.front == '€');
assert(s.length == 3);

s = String("\U00024B62");
cp = s.byCodePoint();
assert(cp.front == '\U00024B62');
assert(s.length == 4);
auto s = const String("Высоцкий");
auto cp1 = s.byCodePoint();
assert(cp1.front == 'В');

auto cp2 = cp1[];
cp1.popFront();
assert(cp1.front == 'ы');
assert(cp2.front == 'В');

cp2 = cp1.save();
cp1.popFront();
assert(cp1.front == 'с');
assert(cp2.front == 'ы');

Meta