Skip to content
CShift0.32

Encoding

Struct · namespace System

struct Encoding

Conversion between strings (always UTF-8 in memory) and raw bytes.

var bytes = Encoding.UTF8().GetBytes("héllo");
if (Encoding.ASCII().GetString(bytes) is string text) { ... }
Name Description
UTF8 The UTF-8 encoding.
ASCII The ASCII encoding.
static Encoding UTF8()

The UTF-8 encoding.

static Encoding ASCII()

The ASCII encoding.

Name Description
Name The name of the encoding: "UTF-8" or "ASCII".
GetBytes The bytes of s in this encoding.
GetByteCount The number of bytes Encoding.GetBytes returns for s.
GetString Decodes all of bytes into a string.
string Name()

The name of the encoding: "UTF-8" or "ASCII".

uint8[] GetBytes(StringSlice s)

The bytes of s in this encoding. UTF-8: the bytes of the string as they are. ASCII: one byte per character; characters above 127 become ?.

int GetByteCount(StringSlice s)

The number of bytes Encoding.GetBytes returns for s.

EncodingError<string> GetString(uint8[] bytes)

Decodes all of bytes into a string.

Errors

EncodingError<string> GetString(uint8[] bytes, int start, int count)

Decodes count bytes of bytes, starting at start, into a string.

Errors