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

Returns true iff it is possible to represent the specified codepoint in the encoding.

The type of encoding cannot be deduced. Therefore, it is necessary to explicitly specify the encoding type.

Prototype

bool canEncode(E)(
  dchar c
);

Standards

Unicode 5.0, ASCII, ISO-8859-1, WINDOWS-1252

Example

assert( canEncode!(Latin1Char)('A'));
assert(!canEncode!(AsciiChar)('\u00A0'));
assert( canEncode!(Latin1Char)('\u00A0'));
assert( canEncode!(Windows1252Char)('\u20AC'));
assert(!canEncode!(Windows1252Char)('\u20AD'));
assert(!canEncode!(Windows1252Char)('\uFFFD'));
assert(!canEncode!(char)(cast(dchar)0x110000));

Authors

Janice Caron

License

Boost License 1.0.

Comments