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.isValidCodeUnit
Returns true if the code unit is legal. For example, the byte 0x80 would not be legal in ASCII, because ASCII code units must always be in the range 0x00 to 0x7F.
Prototype
bool isValidCodeUnit(E)( E c );
Standards
Unicode 5.0, ASCII, ISO-8859-1, WINDOWS-1252
Parameters
Name | Description |
---|---|
c | the code unit to be tested |
Example
assert(!isValidCodeUnit(cast(char)0xC0)); assert(!isValidCodeUnit(cast(char)0xFF)); assert( isValidCodeUnit(cast(wchar)0xD800)); assert(!isValidCodeUnit(cast(dchar)0xD800)); assert(!isValidCodeUnit(cast(AsciiChar)0xA0)); assert( isValidCodeUnit(cast(Windows1252Char)0x80)); assert(!isValidCodeUnit(cast(Windows1252Char)0x81));
Authors
Janice Caron