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.

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

size_t encode(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  out char[4] buf,
  dchar c
) pure @safe;

size_t encode(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  out wchar[2] buf,
  dchar c
) pure @safe;

size_t encode(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  out dchar[1] 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(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  ref char[] str,
  dchar c
) pure @safe;

void encode(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  ref wchar[] str,
  dchar c
) pure @safe;

void encode(std.typecons.Flag!("useReplacementDchar").Flag useReplacementDchar)(
  ref 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