View source code
Display the source code in std/encoding.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.encoding.transcode

Convert a string from one encoding to another.

void transcode(Src, Dst) (
  Src[] s,
  out Dst[] r
);

Supersedes

This function supersedes std.utf.toUTF8(), std.utf.toUTF16() and std.utf.toUTF32() (but note that to!() supersedes it more conveniently).

Standards

Unicode 5.0, ASCII, ISO-8859-1, ISO-8859-2, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252

Parameters

NameDescription
s Source string. Must be validly encoded. This is enforced by the function's in-contract.
r Destination string

See Also

to

Example

wstring ws;
// transcode from UTF-8 to UTF-16
transcode("hello world",ws);
writeln(ws); // "hello world"w

Latin1String ls;
// transcode from UTF-16 to ISO-8859-1
transcode(ws, ls);
writeln(ws); // "hello world"

Authors

Janice Caron

License

Boost License 1.0.