Table of Contents

Struct Char8

Namespace
NumSharp
Assembly
NumSharp.dll

Represents a single byte as a character. Equivalent to NumPy's dtype('S1') / numpy.bytes_ of length 1, and to a Python bytes object of length 1. Interoperable with byte, char (via Latin-1), and string (via ASCII/Latin-1 encoding).

[Serializable]
public readonly struct Char8 : IComparable, IComparable<Char8>, IEquatable<Char8>, IConvertible, ISpanFormattable, IFormattable
Implements
Inherited Members
Extension Methods

Constructors

Char8(byte)

Constructs a Char8 directly from a byte.

public Char8(byte value)

Parameters

value byte

Char8(char)

Constructs a Char8 from a char. Throws if the char cannot be represented in one byte (Latin-1).

public Char8(char value)

Parameters

value char

Fields

MaxValue

The maximum value (0xFF).

public static readonly Char8 MaxValue

Field Value

Char8

MinValue

The minimum value (0x00).

public static readonly Char8 MinValue

Field Value

Char8

Properties

Value

Exposes the raw byte value.

public byte Value { get; }

Property Value

byte

Methods

Abs(Char8)

Returns Max/Min/etc. — INumberBase-style one-offs.

public static Char8 Abs(Char8 value)

Parameters

value Char8

Returns

Char8

AsBytes(ReadOnlySpan<Char8>)

Reinterprets a ReadOnlySpan<T> as ReadOnlySpan<T>. Zero-copy.

public static ReadOnlySpan<byte> AsBytes(ReadOnlySpan<Char8> chars)

Parameters

chars ReadOnlySpan<Char8>

Returns

ReadOnlySpan<byte>

AsBytes(Span<Char8>)

Reinterprets a Span<T> as Span<T>. Zero-copy.

public static Span<byte> AsBytes(Span<Char8> chars)

Parameters

chars Span<Char8>

Returns

Span<byte>

AsChar8s(ReadOnlySpan<byte>)

Reinterprets a ReadOnlySpan<T> as ReadOnlySpan<T>. Zero-copy.

public static ReadOnlySpan<Char8> AsChar8s(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

Returns

ReadOnlySpan<Char8>

AsChar8s(Span<byte>)

Reinterprets a Span<T> as Span<T>. Zero-copy.

public static Span<Char8> AsChar8s(Span<byte> bytes)

Parameters

bytes Span<byte>

Returns

Span<Char8>

Capitalize(ReadOnlySpan<Char8>)

Python b.capitalize() — first byte uppercase, rest lowercase.

public static Char8[] Capitalize(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

CastFrom(byte)

Converts the specified Unicode code point into a UTF-16 encoded string.

public static Char8 CastFrom(byte value)

Parameters

value byte

Returns

Char8

A string consisting of one char object or a surrogate pair of char objects equivalent to the code point specified by the utf32 parameter.

Exceptions

ArgumentOutOfRangeException

utf32 is not a valid 21-bit Unicode code point ranging from U+0 through U+10FFFF, excluding the surrogate pair range from U+D800 through U+DFFF.

CastFrom(char)

Casts a char to Char8 by truncating to 8 bits.

public static Char8 CastFrom(char value)

Parameters

value char

Returns

Char8

CastFrom(int)

Casts an int to Char8 by truncating to 8 bits.

public static Char8 CastFrom(int value)

Parameters

value int

Returns

Char8

CastFrom(uint)

Casts a uint to Char8 by truncating to 8 bits.

public static Char8 CastFrom(uint value)

Parameters

value uint

Returns

Char8

CastFrom(ulong)

Casts a ulong to Char8 by truncating to 8 bits.

public static Char8 CastFrom(ulong value)

Parameters

value ulong

Returns

Char8

CastToUInt32(Char8)

Casts a Char8 to a uint (zero-extends).

public static uint CastToUInt32(Char8 value)

Parameters

value Char8

Returns

uint

Center(ReadOnlySpan<Char8>, int, Char8)

Python b.center(width, fillchar). Uses CPython's formula left = pad/2 + (pad & width & 1) — extra padding goes on the LEFT when pad is odd and width is also odd.

public static Char8[] Center(ReadOnlySpan<Char8> input, int width, Char8 fillChar)

Parameters

input ReadOnlySpan<Char8>
width int
fillChar Char8

Returns

Char8[]

CompareTo(Char8)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(Char8 value)

Parameters

value Char8

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object? value)

Parameters

value object

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

Deconstruct(out byte)

Deconstructs to the underlying byte. Enables pattern matching and assignment like var (b) = char8;.

public void Deconstruct(out byte value)

Parameters

value byte

Equals(Char8)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Char8 other)

Parameters

other Char8

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(byte)

public bool Equals(byte other)

Parameters

other byte

Returns

bool

Equals(char)

public bool Equals(char other)

Parameters

other char

Returns

bool

Equals(int)

public bool Equals(int other)

Parameters

other int

Returns

bool

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromBoolean(bool)

public static Char8 FromBoolean(bool b)

Parameters

b bool

Returns

Char8

FromByte(byte)

public static Char8 FromByte(byte b)

Parameters

b byte

Returns

Char8

FromBytes(byte[])

Copies a byte[] into a new Char8[].

public static Char8[] FromBytes(byte[] bytes)

Parameters

bytes byte[]

Returns

Char8[]

FromChar(char)

Narrows a char to Char8. Throws if the char is outside Latin-1 (> 0xFF).

public static Char8 FromChar(char c)

Parameters

c char

Returns

Char8

FromCharTruncating(char)

Truncates a char to its low byte without bounds checking.

public static Char8 FromCharTruncating(char c)

Parameters

c char

Returns

Char8

FromDecimal(decimal)

public static Char8 FromDecimal(decimal v)

Parameters

v decimal

Returns

Char8

FromDouble(double)

public static Char8 FromDouble(double v)

Parameters

v double

Returns

Char8

FromDoubleArray(ReadOnlySpan<double>, bool)

public static Char8[] FromDoubleArray(ReadOnlySpan<double> src, bool saturating = false)

Parameters

src ReadOnlySpan<double>
saturating bool

Returns

Char8[]

FromDoubleSaturating(double)

Saturates the input to [0, 255] — negative becomes 0, > 255 becomes 255, NaN becomes 0.

public static Char8 FromDoubleSaturating(double v)

Parameters

v double

Returns

Char8

FromInt16(short)

public static Char8 FromInt16(short v)

Parameters

v short

Returns

Char8

FromInt16Truncating(short)

Truncates to 8 bits by masking (always succeeds).

public static Char8 FromInt16Truncating(short v)

Parameters

v short

Returns

Char8

FromInt32(int)

public static Char8 FromInt32(int v)

Parameters

v int

Returns

Char8

FromInt32Array(ReadOnlySpan<int>, bool)

public static Char8[] FromInt32Array(ReadOnlySpan<int> src, bool truncating = false)

Parameters

src ReadOnlySpan<int>
truncating bool

Returns

Char8[]

FromInt32Saturating(int)

Saturates the input to [0, 255] — negative becomes 0, > 255 becomes 255, NaN becomes 0.

public static Char8 FromInt32Saturating(int v)

Parameters

v int

Returns

Char8

FromInt32Truncating(int)

Truncates an int to its low byte without bounds checking.

public static Char8 FromInt32Truncating(int v)

Parameters

v int

Returns

Char8

FromInt64(long)

public static Char8 FromInt64(long v)

Parameters

v long

Returns

Char8

FromInt64Saturating(long)

Saturates the input to [0, 255] — negative becomes 0, > 255 becomes 255, NaN becomes 0.

public static Char8 FromInt64Saturating(long v)

Parameters

v long

Returns

Char8

FromInt64Truncating(long)

Truncates to 8 bits by masking (always succeeds).

public static Char8 FromInt64Truncating(long v)

Parameters

v long

Returns

Char8

FromSByte(sbyte)

public static Char8 FromSByte(sbyte b)

Parameters

b sbyte

Returns

Char8

FromSingle(float)

public static Char8 FromSingle(float v)

Parameters

v float

Returns

Char8

FromStringAscii(string)

Encodes a string to a Char8[] assuming ASCII. Throws if any char is outside 0x00..0x7F. This matches Python's s.encode('ascii').

public static Char8[] FromStringAscii(string s)

Parameters

s string

Returns

Char8[]

FromStringLatin1(string)

Encodes a string to a Char8[] assuming Latin-1 (ISO-8859-1). Throws if any char is outside the 0x00..0xFF range. This matches Python's s.encode('latin-1').

public static Char8[] FromStringLatin1(string s)

Parameters

s string

Returns

Char8[]

FromStringUtf8(string)

Encodes a string as UTF-8 bytes, returning them as Char8[]. This matches Python's s.encode('utf-8').

public static Char8[] FromStringUtf8(string s)

Parameters

s string

Returns

Char8[]

FromUInt16(ushort)

public static Char8 FromUInt16(ushort v)

Parameters

v ushort

Returns

Char8

FromUInt16Truncating(ushort)

Truncates to 8 bits by masking (always succeeds).

public static Char8 FromUInt16Truncating(ushort v)

Parameters

v ushort

Returns

Char8

FromUInt32(uint)

public static Char8 FromUInt32(uint v)

Parameters

v uint

Returns

Char8

FromUInt32Truncating(uint)

Truncates to 8 bits by masking (always succeeds).

public static Char8 FromUInt32Truncating(uint v)

Parameters

v uint

Returns

Char8

FromUInt64(ulong)

public static Char8 FromUInt64(ulong v)

Parameters

v ulong

Returns

Char8

FromUInt64Truncating(ulong)

Truncates to 8 bits by masking (always succeeds).

public static Char8 FromUInt64Truncating(ulong v)

Parameters

v ulong

Returns

Char8

GetByteCount()

Always returns 1 — a Char8 is a single byte.

public int GetByteCount()

Returns

int

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetNumericValue(Char8)

Returns -1.0 for non-digit bytes, 0..9 for '0'..'9'. Full Latin-1 fractions/superscripts (e.g. '¼', '½', '²') are not covered — use GetNumericValue(char) via char.GetNumericValue((char)c) if you need them.

public static double GetNumericValue(Char8 c)

Parameters

c Char8

Returns

double

GetShortestBitLength()

The shortest bit length needed to represent the value (1..8).

public int GetShortestBitLength()

Returns

int

GetTypeCode()

Returns the TypeCode for this instance.

public TypeCode GetTypeCode()

Returns

TypeCode

The enumerated constant that is the TypeCode of the class or value type that implements this interface.

GetUnicodeCategory(Char8)

Latin-1 Unicode category (always defined — every byte maps to Latin-1).

public static UnicodeCategory GetUnicodeCategory(Char8 c)

Parameters

c Char8

Returns

UnicodeCategory

GetUtf8SequenceLength(Char8)

Returns the number of bytes in the UTF-8 sequence whose lead byte is c. Returns 1 for ASCII, 2/3/4 for valid multi-byte leads, 0 for continuation or invalid bytes.

public static int GetUtf8SequenceLength(Char8 c)

Parameters

c Char8

Returns

int

IsAlnum(Char8)

Alias matching Python's bytes.isalnum().

public static bool IsAlnum(Char8 c)

Parameters

c Char8

Returns

bool

IsAlnums(ReadOnlySpan<Char8>)

Python b.isalnum().

public static bool IsAlnums(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsAlpha(Char8)

Alias matching Python's bytes.isalpha().

public static bool IsAlpha(Char8 c)

Parameters

c Char8

Returns

bool

IsAlphas(ReadOnlySpan<Char8>)

Python b.isalpha() — non-empty and every byte is an ASCII letter.

public static bool IsAlphas(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsAscii(Char8)

Returns true if the value is ASCII (0x00..0x7F).

public static bool IsAscii(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiChar(Char8)

Alias matching Python's bytes.isascii().

public static bool IsAsciiChar(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiDigit(Char8)

public static bool IsAsciiDigit(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiHexDigit(Char8)

ASCII hex digit: '0'..'9', 'A'..'F', 'a'..'f'.

public static bool IsAsciiHexDigit(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiHexDigitLower(Char8)

public static bool IsAsciiHexDigitLower(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiHexDigitUpper(Char8)

public static bool IsAsciiHexDigitUpper(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiLetter(Char8)

ASCII letter 'A'..'Z' or 'a'..'z'.

public static bool IsAsciiLetter(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiLetterLower(Char8)

public static bool IsAsciiLetterLower(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiLetterOrDigit(Char8)

public static bool IsAsciiLetterOrDigit(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciiLetterUpper(Char8)

public static bool IsAsciiLetterUpper(Char8 c)

Parameters

c Char8

Returns

bool

IsAsciis(ReadOnlySpan<Char8>)

Python b.isascii() — every byte in [0x00, 0x7F]. Empty → true.

public static bool IsAsciis(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsBetween(Char8, Char8, Char8)

public static bool IsBetween(Char8 c, Char8 minInclusive, Char8 maxInclusive)

Parameters

c Char8
minInclusive Char8
maxInclusive Char8

Returns

bool

IsControl(Char8)

Control character: ASCII 0x00..0x1F or 0x7F (DEL). Also covers C1 0x80..0x9F for parity with IsControl(char).

public static bool IsControl(Char8 c)

Parameters

c Char8

Returns

bool

IsDigit(Char8)

Returns true for ASCII digits '0'..'9'. Non-ASCII bytes return false — matches NumPy / Python's bytes.isdigit(). For Latin-1 digit categories use IsDigitLatin1(Char8).

public static bool IsDigit(Char8 c)

Parameters

c Char8

Returns

bool

IsDigitLatin1(Char8)

Latin-1 digit check: 0x30..0x39 only. There are no decimal digits in Latin-1 supplement.

public static bool IsDigitLatin1(Char8 c)

Parameters

c Char8

Returns

bool

IsDigits(ReadOnlySpan<Char8>)

Python b.isdigit() — non-empty and every byte is '0'..'9'.

public static bool IsDigits(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsEvenInteger(Char8)

public static bool IsEvenInteger(Char8 value)

Parameters

value Char8

Returns

bool

IsHighSurrogate(Char8)

public static bool IsHighSurrogate(Char8 c)

Parameters

c Char8

Returns

bool

IsLetter(Char8)

Returns true for ASCII letters 'A'..'Z' / 'a'..'z'. Non-ASCII bytes return false — matches NumPy / Python's bytes.isalpha(). For Latin-1 letters use IsLetterLatin1(Char8).

public static bool IsLetter(Char8 c)

Parameters

c Char8

Returns

bool

IsLetterLatin1(Char8)

Latin-1 letter check: includes accented letters like 'é' (0xE9).

public static bool IsLetterLatin1(Char8 c)

Parameters

c Char8

Returns

bool

IsLetterOrDigit(Char8)

ASCII letter or digit. Matches Python's bytes.isalnum().

public static bool IsLetterOrDigit(Char8 c)

Parameters

c Char8

Returns

bool

IsLowSurrogate(Char8)

public static bool IsLowSurrogate(Char8 c)

Parameters

c Char8

Returns

bool

IsLower(Char8)

ASCII lowercase 'a'..'z'. Matches Python's bytes.islower() semantics for a single byte.

public static bool IsLower(Char8 c)

Parameters

c Char8

Returns

bool

IsLowerLatin1(Char8)

Latin-1 lowercase letter check.

public static bool IsLowerLatin1(Char8 c)

Parameters

c Char8

Returns

bool

IsLowers(ReadOnlySpan<Char8>)

Python b.islower() — mirror of IsUppers.

public static bool IsLowers(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsNull(Char8)

Returns true if the value is 0 (null). Useful for C-string / null-terminated parsing.

public static bool IsNull(Char8 c)

Parameters

c Char8

Returns

bool

IsNumber(Char8)

Latin-1 number (DecimalDigitNumber..OtherNumber). Includes superscript and fraction chars in Latin-1.

public static bool IsNumber(Char8 c)

Parameters

c Char8

Returns

bool

IsOddInteger(Char8)

public static bool IsOddInteger(Char8 value)

Parameters

value Char8

Returns

bool

IsPow2(Char8)

public static bool IsPow2(Char8 value)

Parameters

value Char8

Returns

bool

IsPrintable(Char8)

Matches Python's bytes.isprintable(): ASCII 0x20..0x7E are printable; all other bytes are not.

public static bool IsPrintable(Char8 c)

Parameters

c Char8

Returns

bool

IsPrintables(ReadOnlySpan<Char8>)

Python b.isprintable() — every byte in 0x20..0x7E. Empty → true.

public static bool IsPrintables(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsPunctuation(Char8)

Latin-1 punctuation (ConnectorPunctuation..OtherPunctuation).

public static bool IsPunctuation(Char8 c)

Parameters

c Char8

Returns

bool

IsSeparator(Char8)

Latin-1 separator (SpaceSeparator..ParagraphSeparator). Only space (0x20) and NBSP (0xA0) qualify in Latin-1.

public static bool IsSeparator(Char8 c)

Parameters

c Char8

Returns

bool

IsSpace(Char8)

Alias matching Python's bytes.isspace().

public static bool IsSpace(Char8 c)

Parameters

c Char8

Returns

bool

IsSpaces(ReadOnlySpan<Char8>)

Python b.isspace().

public static bool IsSpaces(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsSurrogate(Char8)

public static bool IsSurrogate(Char8 c)

Parameters

c Char8

Returns

bool

IsSymbol(Char8)

Latin-1 symbol (MathSymbol..OtherSymbol).

public static bool IsSymbol(Char8 c)

Parameters

c Char8

Returns

bool

IsTitles(ReadOnlySpan<Char8>)

Python b.istitle() — title case alternation of ASCII letters.

public static bool IsTitles(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsUpper(Char8)

ASCII uppercase 'A'..'Z'. Matches Python's bytes.isupper() semantics for a single byte.

public static bool IsUpper(Char8 c)

Parameters

c Char8

Returns

bool

IsUpperLatin1(Char8)

Latin-1 uppercase letter check.

public static bool IsUpperLatin1(Char8 c)

Parameters

c Char8

Returns

bool

IsUppers(ReadOnlySpan<Char8>)

Python b.isupper() — true if at least one cased byte exists and all cased bytes are uppercase. Non-cased bytes are permitted.

public static bool IsUppers(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

bool

IsUtf8ContinuationByte(Char8)

True for UTF-8 continuation bytes (0x80..0xBF).

public static bool IsUtf8ContinuationByte(Char8 c)

Parameters

c Char8

Returns

bool

IsUtf8Invalid(Char8)

True for bytes that are never valid in UTF-8 (0xC0, 0xC1, 0xF5..0xFF).

public static bool IsUtf8Invalid(Char8 c)

Parameters

c Char8

Returns

bool

IsUtf8LeadByte(Char8)

True for UTF-8 lead bytes of multi-byte sequences (0xC2..0xF4).

public static bool IsUtf8LeadByte(Char8 c)

Parameters

c Char8

Returns

bool

IsUtf8SingleByte(Char8)

True for ASCII bytes (0x00..0x7F) — single-byte UTF-8 sequences.

public static bool IsUtf8SingleByte(Char8 c)

Parameters

c Char8

Returns

bool

IsWhiteSpace(Char8)

ASCII whitespace: space, tab, LF, VT, FF, CR. Matches Python's bytes.isspace().

public static bool IsWhiteSpace(Char8 c)

Parameters

c Char8

Returns

bool

IsWhiteSpaceLatin1(Char8)

Latin-1 whitespace check: includes NBSP (0xA0) in addition to ASCII whitespace.

public static bool IsWhiteSpaceLatin1(Char8 c)

Parameters

c Char8

Returns

bool

IsZero(Char8)

public static bool IsZero(Char8 value)

Parameters

value Char8

Returns

bool

Join(ReadOnlySpan<Char8>, Char8[][])

Python separator.join(iterable).

public static Char8[] Join(ReadOnlySpan<Char8> separator, Char8[][] parts)

Parameters

separator ReadOnlySpan<Char8>
parts Char8[][]

Returns

Char8[]

LJust(ReadOnlySpan<Char8>, int, Char8)

Python b.ljust(width, fillchar).

public static Char8[] LJust(ReadOnlySpan<Char8> input, int width, Char8 fillChar)

Parameters

input ReadOnlySpan<Char8>
width int
fillChar Char8

Returns

Char8[]

LStrip(ReadOnlySpan<Char8>)

Python b.lstrip() — strip leading ASCII whitespace.

public static Char8[] LStrip(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

LStrip(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>)

public static Char8[] LStrip(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> chars)

Parameters

input ReadOnlySpan<Char8>
chars ReadOnlySpan<Char8>

Returns

Char8[]

LeadingZeroCount(Char8)

Leading zero count in 8-bit width.

public static Char8 LeadingZeroCount(Char8 value)

Parameters

value Char8

Returns

Char8

Log2(Char8)

public static Char8 Log2(Char8 value)

Parameters

value Char8

Returns

Char8

Lower(ReadOnlySpan<Char8>)

Python b.lower().

public static Char8[] Lower(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

Max(Char8, Char8)

public static Char8 Max(Char8 x, Char8 y)

Parameters

x Char8
y Char8

Returns

Char8

Min(Char8, Char8)

public static Char8 Min(Char8 x, Char8 y)

Parameters

x Char8
y Char8

Returns

Char8

Parse(string)

Parses a one-character string as Char8. Throws if the string is not length 1 or contains a non-Latin-1 char.

public static Char8 Parse(string s)

Parameters

s string

Returns

Char8

Partition(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>)

Python b.partition(sep) — splits on first occurrence, returns (before, sep, after).

public static (Char8[] Before, Char8[] Sep, Char8[] After) Partition(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> separator)

Parameters

input ReadOnlySpan<Char8>
separator ReadOnlySpan<Char8>

Returns

(Char8[] Before, Char8[] Sep, Char8[] After)

PopCount(Char8)

Population count (number of set bits).

public static Char8 PopCount(Char8 value)

Parameters

value Char8

Returns

Char8

RJust(ReadOnlySpan<Char8>, int, Char8)

Python b.rjust(width, fillchar).

public static Char8[] RJust(ReadOnlySpan<Char8> input, int width, Char8 fillChar)

Parameters

input ReadOnlySpan<Char8>
width int
fillChar Char8

Returns

Char8[]

RPartition(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>)

Python b.rpartition(sep) — splits on last occurrence.

public static (Char8[] Before, Char8[] Sep, Char8[] After) RPartition(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> separator)

Parameters

input ReadOnlySpan<Char8>
separator ReadOnlySpan<Char8>

Returns

(Char8[] Before, Char8[] Sep, Char8[] After)

RSplit(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>, int)

Python b.rsplit() — like Split but consumes from the right end.

public static Char8[][] RSplit(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> separator, int maxsplit = -1)

Parameters

input ReadOnlySpan<Char8>
separator ReadOnlySpan<Char8>
maxsplit int

Returns

Char8[][]

RStrip(ReadOnlySpan<Char8>)

Python b.rstrip() — strip trailing ASCII whitespace.

public static Char8[] RStrip(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

RStrip(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>)

public static Char8[] RStrip(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> chars)

Parameters

input ReadOnlySpan<Char8>
chars ReadOnlySpan<Char8>

Returns

Char8[]

Replace(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>, ReadOnlySpan<Char8>, int)

Python b.replace(old, new, count).

public static Char8[] Replace(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> oldValue, ReadOnlySpan<Char8> newValue, int count = -1)

Parameters

input ReadOnlySpan<Char8>
oldValue ReadOnlySpan<Char8>
newValue ReadOnlySpan<Char8>
count int

Returns

Char8[]

RotateLeft(Char8, int)

Rotate left within 8 bits.

public static Char8 RotateLeft(Char8 value, int rotateAmount)

Parameters

value Char8
rotateAmount int

Returns

Char8

RotateRight(Char8, int)

Rotate right within 8 bits.

public static Char8 RotateRight(Char8 value, int rotateAmount)

Parameters

value Char8
rotateAmount int

Returns

Char8

Split(ReadOnlySpan<Char8>, int)

Python b.split() (no args) — splits on runs of ASCII whitespace, no empty elements, max maxsplit splits (negative = unlimited). Matches Python exactly including the "leading whitespace is skipped" rule.

public static Char8[][] Split(ReadOnlySpan<Char8> input, int maxsplit = -1)

Parameters

input ReadOnlySpan<Char8>
maxsplit int

Returns

Char8[][]

Split(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>, int)

Python b.split(sep) — splits on separator, preserves empty elements.

public static Char8[][] Split(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> separator, int maxsplit = -1)

Parameters

input ReadOnlySpan<Char8>
separator ReadOnlySpan<Char8>
maxsplit int

Returns

Char8[][]

SplitLines(ReadOnlySpan<Char8>, bool)

Python bytes.splitlines(keepends) — splits on \n, \r, and \r\n only. Unlike Python's str.splitlines(), bytes does NOT treat \v, \f, \x1c..\x1e, or \x85 as line boundaries.

public static Char8[][] SplitLines(ReadOnlySpan<Char8> input, bool keepEnds = false)

Parameters

input ReadOnlySpan<Char8>
keepEnds bool

Returns

Char8[][]

Strip(ReadOnlySpan<Char8>)

Python b.strip() — strip ASCII whitespace from both ends.

public static Char8[] Strip(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

Strip(ReadOnlySpan<Char8>, ReadOnlySpan<Char8>)

Python b.strip(chars) — strip any byte in chars from both ends.

public static Char8[] Strip(ReadOnlySpan<Char8> input, ReadOnlySpan<Char8> chars)

Parameters

input ReadOnlySpan<Char8>
chars ReadOnlySpan<Char8>

Returns

Char8[]

SwapCase(ReadOnlySpan<Char8>)

Python b.swapcase().

public static Char8[] SwapCase(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

Title(ReadOnlySpan<Char8>)

Python b.title() — titlecase ASCII: uppercase byte after any non-letter byte, lowercase elsewhere.

public static Char8[] Title(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

ToBoolean()

Returns true if the byte is non-zero (C convention).

public bool ToBoolean()

Returns

bool

ToBooleanArray(ReadOnlySpan<Char8>)

public static bool[] ToBooleanArray(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

bool[]

ToByte()

public byte ToByte()

Returns

byte

ToBytes(ReadOnlySpan<Char8>)

Copies a Char8[] into a new byte[].

public static byte[] ToBytes(ReadOnlySpan<Char8> chars)

Parameters

chars ReadOnlySpan<Char8>

Returns

byte[]

ToChar()

Widens to char via Latin-1 (0xE9 → 'é').

public char ToChar()

Returns

char

ToCharArray(ReadOnlySpan<Char8>)

public static char[] ToCharArray(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

char[]

ToDecimal()

public decimal ToDecimal()

Returns

decimal

ToDouble()

public double ToDouble()

Returns

double

ToDoubleArray(ReadOnlySpan<Char8>)

public static double[] ToDoubleArray(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

double[]

ToEscaped()

Returns the Python-style escaped representation — printable ASCII is returned as-is, recognized escapes use their literal form, all others use \xNN.

public string ToEscaped()

Returns

string

ToHex()

Returns the hex representation "0xNN".

public string ToHex()

Returns

string

ToInt16()

Returns the underlying byte as a short.

public short ToInt16()

Returns

short

ToInt16Array(ReadOnlySpan<Char8>)

public static short[] ToInt16Array(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

short[]

ToInt32()

public int ToInt32()

Returns

int

ToInt32Array(ReadOnlySpan<Char8>)

public static int[] ToInt32Array(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

int[]

ToInt64()

public long ToInt64()

Returns

long

ToInt64Array(ReadOnlySpan<Char8>)

public static long[] ToInt64Array(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

long[]

ToLower(Char8)

ASCII lowercase (NumPy parity): bit-flips 'A'..'Z' to 'a'..'z'. Non-ASCII bytes unchanged.

public static Char8 ToLower(Char8 c)

Parameters

c Char8

Returns

Char8

ToLowerInvariant(Char8)

ASCII lowercase (NumPy parity): bit-flips 'A'..'Z' to 'a'..'z'. Non-ASCII bytes unchanged.

public static Char8 ToLowerInvariant(Char8 c)

Parameters

c Char8

Returns

Char8

ToLowerLatin1(Char8)

Latin-1 lowercase: folds 'Á'..'Þ' (0xC0..0xDE, excluding 0xD7) to 'á'..'þ' as well as ASCII letters.

public static Char8 ToLowerLatin1(Char8 c)

Parameters

c Char8

Returns

Char8

ToSByte()

public sbyte ToSByte()

Returns

sbyte

ToSingle()

public float ToSingle()

Returns

float

ToSingleArray(ReadOnlySpan<Char8>)

public static float[] ToSingleArray(ReadOnlySpan<Char8> src)

Parameters

src ReadOnlySpan<Char8>

Returns

float[]

ToString()

Returns a one-character string, mapping the byte to a char via Latin-1.

public override string ToString()

Returns

string

ToString(Char8)

Returns a one-character string for the given Char8.

public static string ToString(Char8 c)

Parameters

c Char8

Returns

string

ToString(IFormatProvider?)

Converts the value of this instance to an equivalent string using the specified culture-specific formatting information.

public string ToString(IFormatProvider? provider)

Parameters

provider IFormatProvider

An IFormatProvider interface implementation that supplies culture-specific formatting information.

Returns

string

A string instance equivalent to the value of this instance.

ToStringAscii(ReadOnlySpan<Char8>)

Decodes a Char8[] as ASCII into a string. Throws if any byte > 0x7F.

public static string ToStringAscii(ReadOnlySpan<Char8> chars)

Parameters

chars ReadOnlySpan<Char8>

Returns

string

ToStringLatin1(ReadOnlySpan<Char8>)

Decodes a Char8[] as Latin-1 into a string. Lossless for all bytes 0x00..0xFF.

public static string ToStringLatin1(ReadOnlySpan<Char8> chars)

Parameters

chars ReadOnlySpan<Char8>

Returns

string

ToStringUtf8(ReadOnlySpan<Char8>)

Decodes a Char8[] as UTF-8 into a string.

public static string ToStringUtf8(ReadOnlySpan<Char8> chars)

Parameters

chars ReadOnlySpan<Char8>

Returns

string

ToUInt16()

public ushort ToUInt16()

Returns

ushort

ToUInt32()

public uint ToUInt32()

Returns

uint

ToUInt64()

public ulong ToUInt64()

Returns

ulong

ToUpper(Char8)

ASCII uppercase (NumPy parity): bit-flips 'a'..'z' to 'A'..'Z'. Non-ASCII bytes unchanged.

public static Char8 ToUpper(Char8 c)

Parameters

c Char8

Returns

Char8

ToUpperInvariant(Char8)

ASCII uppercase (NumPy parity): bit-flips 'a'..'z' to 'A'..'Z'. Non-ASCII bytes unchanged.

public static Char8 ToUpperInvariant(Char8 c)

Parameters

c Char8

Returns

Char8

ToUpperLatin1(Char8)

Latin-1 uppercase: folds 'á'..'þ' (0xE0..0xFE, excluding 0xF7) to 'Á'..'Þ' as well as ASCII letters. Matches ToUpperInvariant(char) over Latin-1.

public static Char8 ToUpperLatin1(Char8 c)

Parameters

c Char8

Returns

Char8

TrailingZeroCount(Char8)

Trailing zero count in 8-bit width (returns 8 for Char8.MinValue).

public static Char8 TrailingZeroCount(Char8 value)

Parameters

value Char8

Returns

Char8

TryFromChar(char, out Char8)

Tries to narrow a char to a Char8. Returns false if the char is outside Latin-1.

public static bool TryFromChar(char c, out Char8 result)

Parameters

c char
result Char8

Returns

bool

TryFromInt32(int, out Char8)

Tries to narrow an int to a Char8. Returns false if outside [0, 255].

public static bool TryFromInt32(int v, out Char8 result)

Parameters

v int
result Char8

Returns

bool

TryParse(string?, out Char8)

public static bool TryParse(string? s, out Char8 result)

Parameters

s string
result Char8

Returns

bool

TryReadBigEndian(ReadOnlySpan<byte>, bool, out Char8)

Reads a Char8 from the last byte of source.

public static bool TryReadBigEndian(ReadOnlySpan<byte> source, bool isUnsigned, out Char8 value)

Parameters

source ReadOnlySpan<byte>
isUnsigned bool
value Char8

Returns

bool

TryReadLittleEndian(ReadOnlySpan<byte>, bool, out Char8)

Reads a Char8 from the last byte of source.

public static bool TryReadLittleEndian(ReadOnlySpan<byte> source, bool isUnsigned, out Char8 value)

Parameters

source ReadOnlySpan<byte>
isUnsigned bool
value Char8

Returns

bool

TryWriteBigEndian(Span<byte>, out int)

Writes the value as a single byte to destination.

public bool TryWriteBigEndian(Span<byte> destination, out int bytesWritten)

Parameters

destination Span<byte>
bytesWritten int

Returns

bool

TryWriteLittleEndian(Span<byte>, out int)

Writes the value as a single byte to destination.

public bool TryWriteLittleEndian(Span<byte> destination, out int bytesWritten)

Parameters

destination Span<byte>
bytesWritten int

Returns

bool

Upper(ReadOnlySpan<Char8>)

Python b.upper() — ASCII bit-flip of each byte.

public static Char8[] Upper(ReadOnlySpan<Char8> input)

Parameters

input ReadOnlySpan<Char8>

Returns

Char8[]

ZFill(ReadOnlySpan<Char8>, int)

Python b.zfill(width) — pads with '0' on the left. Preserves leading '+'/'-' sign byte.

public static Char8[] ZFill(ReadOnlySpan<Char8> input, int width)

Parameters

input ReadOnlySpan<Char8>
width int

Returns

Char8[]

Operators

operator +(Char8, Char8)

public static Char8 operator +(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator +(Char8, byte)

public static Char8 operator +(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

Char8

operator +(Char8, int)

Adds an integer offset, wrapping at byte boundary.

public static Char8 operator +(Char8 left, int right)

Parameters

left Char8
right int

Returns

Char8

operator +(byte, Char8)

public static Char8 operator +(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

Char8

operator +(int, Char8)

public static Char8 operator +(int left, Char8 right)

Parameters

left int
right Char8

Returns

Char8

operator &(Char8, Char8)

public static Char8 operator &(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator |(Char8, Char8)

public static Char8 operator |(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator --(Char8)

public static Char8 operator --(Char8 value)

Parameters

value Char8

Returns

Char8

operator /(Char8, Char8)

public static Char8 operator /(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator ==(Char8, Char8)

public static bool operator ==(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator ==(Char8, byte)

public static bool operator ==(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator ==(Char8, char)

public static bool operator ==(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator ==(Char8, int)

public static bool operator ==(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator ==(byte, Char8)

public static bool operator ==(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator ==(char, Char8)

public static bool operator ==(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator ==(int, Char8)

public static bool operator ==(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

operator ^(Char8, Char8)

public static Char8 operator ^(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

explicit operator Char8(char)

Narrows from char. Throws if the char is outside Latin-1 (> 0xFF).

public static explicit operator Char8(char c)

Parameters

c char

Returns

Char8

explicit operator Char8(int)

Narrows from int. Throws if the int is outside [0, 255].

public static explicit operator Char8(int v)

Parameters

v int

Returns

Char8

operator >(Char8, Char8)

public static bool operator >(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator >(Char8, byte)

public static bool operator >(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator >(Char8, char)

public static bool operator >(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator >(Char8, int)

public static bool operator >(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator >(byte, Char8)

public static bool operator >(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator >(char, Char8)

public static bool operator >(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator >(int, Char8)

public static bool operator >(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

operator >=(Char8, Char8)

public static bool operator >=(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator >=(Char8, byte)

public static bool operator >=(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator >=(Char8, char)

public static bool operator >=(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator >=(Char8, int)

public static bool operator >=(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator >=(byte, Char8)

public static bool operator >=(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator >=(char, Char8)

public static bool operator >=(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator >=(int, Char8)

public static bool operator >=(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

implicit operator byte(Char8)

public static implicit operator byte(Char8 c)

Parameters

c Char8

Returns

byte

implicit operator char(Char8)

Widens to char via Latin-1 (byte 0xE9 -> char 'é' at U+00E9).

public static implicit operator char(Char8 c)

Parameters

c Char8

Returns

char

implicit operator int(Char8)

public static implicit operator int(Char8 c)

Parameters

c Char8

Returns

int

implicit operator uint(Char8)

public static implicit operator uint(Char8 c)

Parameters

c Char8

Returns

uint

implicit operator Char8(byte)

public static implicit operator Char8(byte b)

Parameters

b byte

Returns

Char8

operator ++(Char8)

public static Char8 operator ++(Char8 value)

Parameters

value Char8

Returns

Char8

operator !=(Char8, Char8)

public static bool operator !=(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator !=(Char8, byte)

public static bool operator !=(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator !=(Char8, char)

public static bool operator !=(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator !=(Char8, int)

public static bool operator !=(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator !=(byte, Char8)

public static bool operator !=(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator !=(char, Char8)

public static bool operator !=(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator !=(int, Char8)

public static bool operator !=(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

operator <<(Char8, int)

public static Char8 operator <<(Char8 value, int shift)

Parameters

value Char8
shift int

Returns

Char8

operator <(Char8, Char8)

public static bool operator <(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator <(Char8, byte)

public static bool operator <(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator <(Char8, char)

public static bool operator <(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator <(Char8, int)

public static bool operator <(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator <(byte, Char8)

public static bool operator <(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator <(char, Char8)

public static bool operator <(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator <(int, Char8)

public static bool operator <(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

operator <=(Char8, Char8)

public static bool operator <=(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

bool

operator <=(Char8, byte)

public static bool operator <=(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

bool

operator <=(Char8, char)

public static bool operator <=(Char8 left, char right)

Parameters

left Char8
right char

Returns

bool

operator <=(Char8, int)

public static bool operator <=(Char8 left, int right)

Parameters

left Char8
right int

Returns

bool

operator <=(byte, Char8)

public static bool operator <=(byte left, Char8 right)

Parameters

left byte
right Char8

Returns

bool

operator <=(char, Char8)

public static bool operator <=(char left, Char8 right)

Parameters

left char
right Char8

Returns

bool

operator <=(int, Char8)

public static bool operator <=(int left, Char8 right)

Parameters

left int
right Char8

Returns

bool

operator %(Char8, Char8)

public static Char8 operator %(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator *(Char8, Char8)

public static Char8 operator *(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator ~(Char8)

public static Char8 operator ~(Char8 value)

Parameters

value Char8

Returns

Char8

operator >>(Char8, int)

public static Char8 operator >>(Char8 value, int shift)

Parameters

value Char8
shift int

Returns

Char8

operator -(Char8, Char8)

public static Char8 operator -(Char8 left, Char8 right)

Parameters

left Char8
right Char8

Returns

Char8

operator -(Char8, byte)

public static Char8 operator -(Char8 left, byte right)

Parameters

left Char8
right byte

Returns

Char8

operator -(Char8, int)

public static Char8 operator -(Char8 left, int right)

Parameters

left Char8
right int

Returns

Char8

operator -(Char8)

public static Char8 operator -(Char8 value)

Parameters

value Char8

Returns

Char8

operator +(Char8)

public static Char8 operator +(Char8 value)

Parameters

value Char8

Returns

Char8