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

std.utf.encode - multiple declarations

Function encode

Encodes c into the static array, buf, and returns the actual length of the encoded character (a number between 1 and 4 for char[4] buffers and a number between 1 and 2 for wchar[2] buffers).

Prototypes

ulong encode(
  char[4] buf,
  dchar c
) pure @safe;

ulong encode(
  wchar[2] buf,
  dchar c
) pure @safe;

Throws

UTFException if c is not a valid UTF code point.

Function encode

Encodes c in str's encoding and appends it to str.

Prototypes

void encode(
  char[] str,
  dchar c
) pure @safe;

void encode(
  wchar[] str,
  dchar c
) pure @safe;

void encode(
  dchar[] str,
  dchar c
) pure @safe;

Throws

UTFException if c is not a valid UTF code point.

Authors

Walter Bright and Jonathan M Davis

License

Boost License 1.0.

Comments