View source code
Display the source code in std/utf.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.utf.toUTF32

Encodes the elements of s to UTF-32 and returns a newly GC allocated dstring of the elements.

dstring toUTF32(S) (
  S s
)
if (isInputRange!S && !isInfinite!S && isSomeChar!(ElementEncodingType!S));

Parameters

NameDescription
s the range to encode

Returns

A UTF-32 string

See Also

For a lazy, non-allocating version of these functions, see byUTF.

Example

import std.algorithm.comparison : equal;

// these graphemes are two code units in UTF-16 and one in UTF-32
writeln("𤭢"w.length); // 2
writeln("𐐷"w.length); // 2

assert("𤭢"w.toUTF32.equal([0x00024B62]));
assert("𐐷"w.toUTF32.equal([0x00010437]));

Authors

Walter Bright and Jonathan M Davis

License

Boost License 1.0.