Rune.DecodeFromUtf16(ReadOnlySpan<Char>, Rune, Int32) Método

Definição

Decodifica o Rune no início do buffer de origem UTF-16 fornecido.Decodes the Rune at the beginning of the provided UTF-16 source buffer.

public:
 static System::Buffers::OperationStatus DecodeFromUtf16(ReadOnlySpan<char> source, [Runtime::InteropServices::Out] System::Text::Rune % result, [Runtime::InteropServices::Out] int % charsConsumed);
public static System.Buffers.OperationStatus DecodeFromUtf16 (ReadOnlySpan<char> source, out System.Text.Rune result, out int charsConsumed);
static member DecodeFromUtf16 : ReadOnlySpan<char> * Rune * int -> System.Buffers.OperationStatus
Public Shared Function DecodeFromUtf16 (source As ReadOnlySpan(Of Char), ByRef result As Rune, ByRef charsConsumed As Integer) As OperationStatus

Parâmetros

source
ReadOnlySpan<Char>

Um intervalo de caracteres UTF-16 somente leitura.A read-only UTF-16 character span.

result
Rune

Quando este método é retornado, o símbolo decodificado.When this method returns, the decoded rune.

charsConsumed
Int32

Quando este método é retornado, o número de caracteres lidos para criar o símbolo.When this method returns, the number of characters read to create the rune.

Retornos

OperationStatus

Done se o buffer de origem começar com um valor escalar codificado UTF-16 válido.Done if the source buffer begins with a valid UTF-16 encoded scalar value. result, então, contém o Rune decodificado e charsConsumed contém o número de valores Char usados no buffer de entrada para codificar o Rune.result then contains the decoded Rune, and charsConsumed contains the number of Char values used in the input buffer to encode the Rune.

NeedMoreData se o buffer de origem estiver vazio ou contiver apenas um caractere UTF-16 alternativo superior.NeedMoreData if the source buffer is empty or contains only a standalone UTF-16 high surrogate character. result, então, contém ReplacementChar, e charsConsumed contém o comprimento do buffer de entrada.result then contains ReplacementChar, and charsConsumed contains the length of the input buffer.

InvalidData se o buffer de origem começar com um valor escalar codificado em UTF-16 malformado.InvalidData if the source buffer begins with an ill-formed UTF-16 encoded scalar value. result, então, contém ReplacementChar, e charsConsumed contém o número de valores de Char usados para codificar a sequência malformada.result then contains ReplacementChar, and charsConsumed contains the number of Char values used to encode the ill-formed sequence. ..

Comentários

A Convenção geral é chamar esse método em um loop, source dividindo o buffer por charsConsumed elementos em cada iteração do loop.The general convention is to call this method in a loop, slicing the source buffer by charsConsumed elements on each iteration of the loop. Em cada iteração do loop, result contém o valor real escalar se os dados tiverem sido decodificados com êxito ou Rune.ReplacementChar se os dados não tiverem sido decodificados com êxito.On each iteration of the loop, result contains the real scalar value if the data was successfully decoded, or it contains Rune.ReplacementChar if the data was not successfully decoded. Esse padrão fornece substituição de U + FFFD automática e conveniente de sequências inválidas durante a iteração pelo loop.This pattern provides convenient automatic U+FFFD substitution of invalid sequences while iterating through the loop.

Aplica-se a