Utf8CsvField Struct

  • Obsolete: Types with embedded references are not supported in this version of your compiler.

The value of a column of a Utf8CsvRecord. It is valid until the next record is read.

[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
public readonly ref struct Utf8CsvField

Properties

NameDescription
ColumnIndexGets the 0-based index of the column.
IsEmptyGets a value indicating whether the value is empty.
IsQuotedGets a value indicating whether the value is quoted in the data.
RawUtf8SpanGets the UTF-8 bytes of the value, as they are in the data.
Utf8SpanGets the UTF-8 bytes of the value, without its quotes, with escaped quotes unescaped and trimmed as CsvReaderOptions.Trim says.

ColumnIndex

Utf8CsvField.cs

Gets the 0-based index of the column.

public int ColumnIndex { get; }

Property value

int

Gets a value indicating whether the value is empty.

public bool IsEmpty { get; }

Property value

bool

Gets a value indicating whether the value is quoted in the data.

public bool IsQuoted { get; }

Property value

bool

RawUtf8Span

Utf8CsvField.cs

Gets the UTF-8 bytes of the value, as they are in the data.

public ReadOnlySpan<byte> RawUtf8Span { get; }

Property value

ReadOnlySpan<byte>

Gets the UTF-8 bytes of the value, without its quotes, with escaped quotes unescaped and trimmed as CsvReaderOptions.Trim says.

public ReadOnlySpan<byte> Utf8Span { get; }

Property value

ReadOnlySpan<byte>

Methods

NameDescription
Parse<T>()Parses the UTF-8 bytes of the value with CsvReaderOptions.FormatProvider.
ParseEnum<TEnum>(bool)Parses the value as the name or the number of a member of an enumeration.
ParseUtf16<T>()Decodes the value to UTF-16 and parses it with CsvReaderOptions.FormatProvider.
ToString()Gets the value as a string. Invalid UTF-8 sequences are replaced with U+FFFD.
TryParse<T>(T)Tries to parse the UTF-8 bytes of the value with CsvReaderOptions.FormatProvider.
TryParseUtf16<T>(T)Decodes the value to UTF-16 and tries to parse it with CsvReaderOptions.FormatProvider.

Parse<T>()

Utf8CsvField.cs

Parses the UTF-8 bytes of the value with CsvReaderOptions.FormatProvider.

public T Parse<T>() where T : IUtf8SpanParsable<T>

Type parameters

T
The type to parse the value to.

Returns

T The parsed value.

Exceptions

CsvException
The value is not valid for T.

Remarks

Use Utf8CsvField.ParseUtf16 for the types that cannot parse UTF-8, such as DateTime.

ParseEnum<TEnum>(bool)

Utf8CsvField.cs

Parses the value as the name or the number of a member of an enumeration.

public TEnum ParseEnum<TEnum>(bool ignoreCase = true) where TEnum : struct, Enum

Type parameters

TEnum
The type of the enumeration.

Parameters

ignoreCase bool
true to ignore the case of the name.

Returns

TEnum The parsed value.

Exceptions

CsvException
The value is not valid for TEnum.

ParseUtf16<T>()

Utf8CsvField.cs

Decodes the value to UTF-16 and parses it with CsvReaderOptions.FormatProvider.

public T ParseUtf16<T>() where T : ISpanParsable<T>

Type parameters

T
The type to parse the value to.

Returns

T The parsed value.

Exceptions

CsvException
The value is not valid for T.

ToString()

Utf8CsvField.cs

Gets the value as a string. Invalid UTF-8 sequences are replaced with U+FFFD.

public override string ToString()

Returns

string The value.

TryParse<T>(T)

Utf8CsvField.cs

Tries to parse the UTF-8 bytes of the value with CsvReaderOptions.FormatProvider.

public bool TryParse<T>(out T result) where T : IUtf8SpanParsable<T>

Type parameters

T
The type to parse the value to.

Parameters

result T
The parsed value.

Returns

bool true when the value is valid for T; otherwise, false.

TryParseUtf16<T>(T)

Utf8CsvField.cs

Decodes the value to UTF-16 and tries to parse it with CsvReaderOptions.FormatProvider.

public bool TryParseUtf16<T>(out T result) where T : ISpanParsable<T>

Type parameters

T
The type to parse the value to.

Parameters

result T
The parsed value.

Returns

bool true when the value is valid for T; otherwise, false.