Utf8.FromUtf16 Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Converts a UTF-16 character span to a UTF-8 encoded byte span.
public static System.Buffers.OperationStatus FromUtf16 (ReadOnlySpan<char> source, Span<byte> destination, out int charsRead, out int bytesWritten, bool replaceInvalidSequences = true, bool isFinalBlock = true);
static member FromUtf16 : ReadOnlySpan<char> * Span<byte> * int * int * bool * bool -> System.Buffers.OperationStatus
Public Shared Function FromUtf16 (source As ReadOnlySpan(Of Char), destination As Span(Of Byte), ByRef charsRead As Integer, ByRef bytesWritten As Integer, Optional replaceInvalidSequences As Boolean = true, Optional isFinalBlock As Boolean = true) As OperationStatus
Parameters
- source
- ReadOnlySpan<Char>
A UTF-16 encoded read-only character span.
- charsRead
- Int32
When the method returns, the number of characters read from source
.
- bytesWritten
- Int32
When the method returns, the number of bytes written to destination
.
- replaceInvalidSequences
- Boolean
true
to replace invalid UTF-16 sequences in source
with U+FFFD; false
to return InvalidData if invalid characters are found in source
.
- isFinalBlock
- Boolean
true
if the method should not return NeedMoreData; otherwise, false
.
Returns
A value that indicates that status of the conversion.
Remarks
This method corresponds to the UTF8Encoding.GetBytes method, except that it has a different calling convention, different error handling mechanisms, and different performance characteristics.
If 'replaceInvalidSequences' is true
, the method replaces any ill-formed subsequences in source
with U+FFFD in destination
and continues processing the remainder of the buffer. Otherwise, the method returns OperationStatus.InvalidData if it encounters any ill-formed sequences.
If the method returns an error code, the out parameters indicate how much of the data was successfully transcoded, and the location of the ill-formed subsequence can be deduced from these values.
If 'replaceInvalidSequences' is true
, the method never returns OperationStatus.InvalidData. If 'isFinalBlock' is true
, the method never returns OperationStatus.NeedMoreData.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기