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.

std.encoding.encode - multiple declarations

Function encode

Encodes a single code point.

E[] encode(E) (
  dchar c
);

This function encodes a single code point into one or more code units. It returns a string containing those code units.

The input to this function MUST be a valid code point. This is enforced by the function's in-contract.

The type of the output cannot be deduced. Therefore, it is necessary to explicitly specify the encoding as a template parameter.

Supersedes

This function supersedes std.utf.encode(), however, note that the function codeUnits() supersedes it more conveniently.

Standards

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

Parameters

NameDescription
c the code point to be encoded

Function encode

Encodes a single code point into an array.

size_t encode(E) (
  dchar c,
  E[] array
);

This function encodes a single code point into one or more code units The code units are stored in a user-supplied fixed-size array, which must be passed by reference.

The input to this function MUST be a valid code point. This is enforced by the function's in-contract.

The type of the output cannot be deduced. Therefore, it is necessary to explicitly specify the encoding as a template parameter.

Supersedes

This function supersedes std.utf.encode(), however, note that the function codeUnits() supersedes it more conveniently.

Standards

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

Parameters

NameDescription
c the code point to be encoded
array the destination array

Returns

the number of code units written to the array

Function encode

Encodes a single code point to a delegate.

void encode(E) (
  dchar c,
  void delegate(E) dg
);

This function encodes a single code point into one or more code units. The code units are passed one at a time to the supplied delegate.

The input to this function MUST be a valid code point. This is enforced by the function's in-contract.

The type of the output cannot be deduced. Therefore, it is necessary to explicitly specify the encoding as a template parameter.

Supersedes

This function supersedes std.utf.encode(), however, note that the function codeUnits() supersedes it more conveniently.

Standards

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

Parameters

NameDescription
c the code point to be encoded
dg the delegate to invoke for each code unit

Function encode

Encodes the contents of s in units of type Tgt, writing the result to an output range.

size_t encode(Tgt, Src, R) (
  in Src[] s,
  R range
);

Returns

The number of Tgt elements written.

Parameters

NameDescription
Tgt Element type of range.
s Input array.
range Output range.

Authors

Janice Caron

License

Boost License 1.0.