CharacterEncoding

Description

[ShutdownSurvive]
abstract class Tinman.Core.Formatting.CharacterEncoding

Derived from

ICharacterEscape

Extended by

CharacterEncodingSimple abstract

Base class for single-byte and multi-byte character encodings.

Public / Constants

Decode​Replacement


public constant DecodeReplacement → ((char) 0xFFFD:char)

The default replacement character for decoding: U+FFFD

Simple​Http


[ShutdownSurvive]
public static readonly attribute SimpleHttp → (ISimpleHttpText)

A ISimpleHttpText object that uses the built-in character encoding to decode text data.

See also

ISimpleHttp

UTF_16_​BE


public static readonly attribute UTF_16_BE → (CharacterEncoding)

Character encoding UTF-16 (big-endian).

UTF_16_​LE


public static readonly attribute UTF_16_LE → (CharacterEncoding)

Character encoding UTF-16 (little-endian).

UTF_32_​BE


public static readonly attribute UTF_32_BE → (CharacterEncoding)

Character encoding UTF-32 (big-endian).

UTF_32_​LE


public static readonly attribute UTF_32_LE → (CharacterEncoding)

Character encoding UTF-32 (little-endian).

UTF_8


public static readonly attribute UTF_8 → (CharacterEncoding)

Character encoding UTF-8.

Public / Constructors

For


public static method For → (2)

name in : string

The name or null.

defaultEncoding opt : CharacterEncoding = null

The default encoding to return in case name in is not recognized. Defaults to null.

returns → CharacterEncoding

The found encoding or null.

Returns a character encoding by its name.

The given name is normalized before trying to find a character encoding: First, the name is converted to lower-case. Then, all characters that are neither letters nor digits are removed (i.e. only '0'..'9', 'a'..'z' are retained). The resulting normalized name is then tested against the following values in order to find a character encoding:

Public / Methods

Decode

2 overloads


public abstract method Decode1 → (2)

input in : ByteBuffer

[not-null]
The input buffer.

replacement opt : int32 = CharacterEncoding.DecodeReplacement

The replacement character to use for codes that cannot be decoded.

returns → int32

The decoded Unicode character or -1 iff the given buffer does not contain any more characters.

Decodes a single Unicode character.


public abstract method Decode2 → (2)

input in : IDataStream

[not-null]
The input buffer.

replacement opt : int32 = CharacterEncoding.DecodeReplacement

The replacement character to use for codes that cannot be decoded.

returns → int32

The decoded Unicode character or -1 iff the given buffer does not contain any more characters.

Decodes a single Unicode character.

IOException

If an I/O error has occurred.

Decode​String


public method DecodeString → (2)

bytes in : ByteBuffer

The encoded string.

replacement opt : int32 = CharacterEncoding.DecodeReplacement

The replacement character to use for codes that cannot be decoded.

returns → string

The UTF-16 code unit sequence or null iff bytes in is null.

Converts the given encoded string to a UTF-16 code unit sequence.

Encode

2 overloads


public abstract method Encode1 → (2)

character in : int32

The Unicode character.

output in : ByteBuffer

[not-null]
The output buffer.

returns → int32

The number of bytes that have been written to output in if there was enough space left; -n if the buffer does not have enough space left, where n is then the number of bytes that would have been written. Will be 0 iff the given character in cannot be encoded.

Encodes the given Unicode character.


public abstract method Encode2 → (2)

character in : int32

The Unicode character.

output in : IDataStream

[not-null]
The output buffer.

returns → int32

The number of bytes that have been written to output in. Will be 0 iff the given character in cannot be encoded.

Encodes the given Unicode character.

IOException

If an I/O error has occurred.

Encode​Count


[Pure]
public abstract method EncodeCount → (1)

character in : int32

The Unicode character.

returns → int32

The number of bytes that are required to encode the given Unicode character. Will be 0 iff character in cannot be encoded.

Returns the number of bytes that are required to encode the given Unicode character.

Encode​String


[OwnerReturn]
public method EncodeString → (2)

characters in : string

UTF-16 code unit sequence.

bytes opt : ByteBuffer own = null

The output buffer (can be null).

returns → ByteBuffer

The resulting buffer or null iff characters in is null.

Converts the given UTF-16 code unit sequence to an encoded string.

Characters that cannot be encoded will be replaced with the code for EncodeReplacement. The encoded bytes will be written to bytes opt beginning at the current buffer position. Before returning, this method sets the ByteBuffer.Position and ByteBuffer.Limit to the range of encoded bytes that have been output.

Encode​String​Count


[Pure]
public method EncodeStringCount → (1)

characters in : string

UTF-16 code unit sequence.

returns → int32

The number of bytes that are required to encode the given Unicode character.

Returns the number of bytes that are required to encode the given UTF-16 code unit sequence.

Public / Attributes

Encode​Count​Range


[Constant]
public abstract attribute EncodeCountRange → (get)

value : RangeI

[>=0]
The range of the number of bytes per character.

Returns the number of bytes per character (for valid input code points).

Encode​Replacement


[Constant]
public virtual attribute EncodeReplacement → (get)

value : char

The replacement character for encoding.

Returns the replacement character that is used for encoding when a character cannot be represented.

The default implementation returns DecodeReplacement.

Encode​Replacement​Count


[Constant]
public abstract attribute EncodeReplacementCount → (get)

value : int32

[>=1]
The number of bytes.

Returns the number of bytes that are required to encode EncodeReplacement.

Name


public abstract attribute Name → (get)

value : string

[not-null]
The encoding name.

Returns the name of this character encoding.