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.

Class std.encoding.EncodingSchemeUtf8

EncodingScheme to handle UTF-8

class EncodingSchemeUtf8
  : EncodingScheme ;

This scheme recognises the following names: "UTF-8"

Properties

NameTypeDescription
replacementSequence[get] immutable(ubyte)[]Returns the sequence of ubytes to be used to represent any character which cannot be represented in the encoding scheme.

Methods

NameDescription
canEncode (c) Returns true if the character c can be represented in this encoding scheme.
count (s) Returns the total number of code points encoded in a ubyte array.
create (encodingName) Obtains a subclass of EncodingScheme which is capable of encoding and decoding the named encoding scheme.
decode (s) Decodes a single code point.
encode (c, buffer) Encodes a single code point into a user-supplied, fixed-size buffer.
encodedLength (c) Returns the number of ubytes required to encode this code point.
factory (classname) Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.
firstSequence (s) Returns the length of the first encoded sequence.
index (s, n) Returns the array index at which the (n+1)th code point begins.
isValid (s) Returns true if the array is encoded correctly
names () Returns an array of all known names for this encoding scheme
opCmp (o) Compare with another Object obj.
opEquals (o) Test whether this is equal to o. The default implementation only compares by identity (using the is operator). Generally, overrides and overloads for opEquals should attempt to compare objects by their contents. A class will most likely want to add an overload that takes your specific type as the argument and does the content comparison. Then you can override this and forward it to your specific typed overload with a cast. Remember to check for null on the typed overload.
register () Registers a subclass of EncodingScheme.
safeDecode (s) Decodes a single code point. The input does not have to be valid.
sanitize (s) Sanitizes an array by replacing malformed ubyte sequences with valid ubyte sequences. The result is guaranteed to be valid for this encoding scheme.
toHash () Compute hash function for Object.
toString () Returns the standard name of the encoding scheme
toString () Convert Object to a human readable string.
validLength (s) Returns the length of the longest possible substring, starting from the first element, which is validly encoded.

Authors

Janice Caron

License

Boost License 1.0.