Rune.DecodeLastFromUtf8(ReadOnlySpan<Byte>, Rune, Int32) 方法

定義

解碼所提供 UTF-8 來源緩衝區結尾的 Rune

public:
 static System::Buffers::OperationStatus DecodeLastFromUtf8(ReadOnlySpan<System::Byte> source, [Runtime::InteropServices::Out] System::Text::Rune % value, [Runtime::InteropServices::Out] int % bytesConsumed);
public static System.Buffers.OperationStatus DecodeLastFromUtf8 (ReadOnlySpan<byte> source, out System.Text.Rune value, out int bytesConsumed);
static member DecodeLastFromUtf8 : ReadOnlySpan<byte> * Rune * int -> System.Buffers.OperationStatus
Public Shared Function DecodeLastFromUtf8 (source As ReadOnlySpan(Of Byte), ByRef value As Rune, ByRef bytesConsumed As Integer) As OperationStatus

參數

source
ReadOnlySpan<Byte>

唯讀 UTF-8 編碼位元組範圍。

value
Rune

當此方法傳回時,會是已解碼的 rune。

bytesConsumed
Int32

當此方法傳回時,會是讀取以建立 rune 的位元組數目。

傳回

如果來源緩衝區是以有效的 UTF-8 編碼純量值結尾,則為 Doneresult 則會包含已解碼的 Rune,且 bytesConsumed 會包含輸入緩衝區中用來編碼 RuneByte 值數目。

如果來源緩衝區是空的或只包含獨立 UTF-8 高代理字元,則為 NeedMoreDataresult 則會包含 ReplacementChar,且 bytesConsumed 會包含輸入緩衝區的長度。

如果來源緩衝區是以語式錯誤的 UTF-8 編碼純量值結尾,則為 InvalidDataresult 則會包含 ReplacementChar,且 bytesConsumed 會包含輸入緩衝區中用來編碼語式錯誤序列的 Byte 值數目。

備註

這個方法與 非常類似 DecodeFromUtf8(ReadOnlySpan<Byte>, Rune, Int32) ,不同之處在于它可讓呼叫端回溯迴圈,而不是向前迴圈。 典型的呼叫慣例是在迴圈的每個反復專案上,呼叫端應該將緩衝區的最後 bytesConsumed 元素 source 配量。

適用於