View source code Display the source code in std/string.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.string.assumeUTF

Assume the given array of integers arr is a well-formed UTF string and return it typed as a UTF string.

ubyte becomes char, ushort becomes wchar and uint becomes dchar. Type qualifiers are preserved.

Prototype

auto pure assumeUTF(T)(
  T[] arr
)
if (staticIndexOf!(Unqual!T, ubyte, ushort, uint) != -1);

Parameters

NameDescription
arr array of bytes, ubytes, shorts, ushorts, ints, or uints

Returns

arr retyped as an array of chars, wchars, or dchars

See Also

representation

Example

string a = "Hölo World";
immutable(ubyte)[] b = a.representation;
string c = b.assumeUTF;

assert(a == c);

Authors

Walter Bright, Andrei Alexandrescu, and Jonathan M Davis

License

Boost License 1.0.

Comments