Rune.TryEncodeToUtf8(Span<Byte>, Int32) Method

Definition

将此 Rune 解码为 UTF-8 编码目标缓冲区。Encodes this Rune to a UTF-8 encoded destination buffer.

public:
 bool TryEncodeToUtf8(Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public bool TryEncodeToUtf8 (Span<byte> destination, out int bytesWritten);
member this.TryEncodeToUtf8 : Span<byte> * int -> bool
Public Function TryEncodeToUtf8 (destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

Parameters

destination
Span<Byte>

UTF-8 编码值写入到的缓冲区。The buffer to which to write the UTF-8 encoded value.

bytesWritten
Int32

写入 destinationByte 值的数目,或者如果目标缓冲区大小不足以包含输出,则为 0。The number of Byte values written to destination, or 0 if the destination buffer is not large enough to contain the output.

Returns

Boolean

如果该值已写入缓冲区,则为 true;否则为 falsetrue if the value was written to the buffer; otherwise, false.

Remarks

可以提前查询 Utf8SequenceLength 属性,以确定 destination 缓冲区的所需大小。The Utf8SequenceLength property can be queried ahead of time to determine the required size of the destination buffer.

Applies to