docs.unity.cn
    Show / Hide Table of Contents

    Class UTF8ArrayUnsafeUtility

    Provides methods for copying and encoding Unicode text.

    Inheritance
    Object
    UTF8ArrayUnsafeUtility
    Namespace: Unity.Collections
    Syntax
    public static class UTF8ArrayUnsafeUtility

    Methods

    Append(Byte*, ref UInt16, UInt16, Byte*, UInt16)

    Appends UTF-8 text to a buffer.

    Declaration
    public static CopyError Append(byte *dest, ref ushort destLength, ushort destUTF8MaxLengthInBytes, byte *src, ushort srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer.

    UInt16 destLength

    Reference to the destination buffer's length in bytes before the append. Will be assigned the number of bytes appended.

    UInt16 destUTF8MaxLengthInBytes

    The destination buffer's length in bytes. Data will not be appended past this length.

    Byte* src

    The source buffer.

    UInt16 srcLength

    The number of bytes to read from the source.

    Returns
    Type Description
    CopyError

    None if the append fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    Append(Byte*, ref UInt16, UInt16, Char*, Int32)

    Appends UCS-2 text to a buffer, encoded as UTF-8.

    Declaration
    public static CopyError Append(byte *dest, ref ushort destLength, ushort destUTF8MaxLengthInBytes, char *src, int srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer.

    UInt16 destLength

    Reference to the destination buffer's length in bytes before the append. Will be assigned the number of bytes appended.

    UInt16 destUTF8MaxLengthInBytes

    The destination buffer's length in bytes. Data will not be appended past this length.

    Char* src

    The source buffer.

    Int32 srcLength

    The number of chars to read from the source.

    Returns
    Type Description
    CopyError

    None if the append fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UCS-2.

    Append(Char*, ref UInt16, UInt16, Byte*, UInt16)

    Appends UTF-8 text to a buffer, encoded as UCS-2.

    Declaration
    public static CopyError Append(char *dest, ref ushort destLength, ushort destUCS2MaxLengthInChars, byte *src, ushort srcLength)
    Parameters
    Type Name Description
    Char* dest

    The destination buffer.

    UInt16 destLength

    Reference to the destination buffer's length in chars before the append. Will be assigned the number of chars appended.

    UInt16 destUCS2MaxLengthInChars

    The destination buffer's length in chars. Data will not be appended past this length.

    Byte* src

    The source buffer.

    UInt16 srcLength

    The number of bytes to read from the source.

    Returns
    Type Description
    CopyError

    None if the append fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    AppendUTF8Bytes(Byte*, ref Int32, Int32, Byte*, Int32)

    Appends UTF-8 text to a buffer.

    Declaration
    public static FormatError AppendUTF8Bytes(byte *dest, ref int destLength, int destCapacity, byte *src, int srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer.

    Int32 destLength

    Reference to the destination buffer's length in bytes before the append. Will be assigned the new length after the append.

    Int32 destCapacity

    The destination buffer capacity in bytes.

    Byte* src

    The source buffer.

    Int32 srcLength

    The number of bytes to read from the source.

    Returns
    Type Description
    FormatError

    None if the append fully completes. Otherwise, returns Overflow.

    Remarks

    Assumes the source data is valid UTF-8.

    No data will be copied if the destination has insufficient capacity for the full append, i.e. if srcLength > (destCapacity - destLength).

    Copy(Byte*, out Int32, Int32, Byte*, Int32)

    Copies a buffer of UCS-8 text.

    Declaration
    public static CopyError Copy(byte *dest, out int destLength, int destUTF8MaxLengthInBytes, byte *src, int srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer.

    Int32 destLength

    Outputs the number of bytes written to the destination.

    Int32 destUTF8MaxLengthInBytes

    The max number of bytes that will be written to the destination buffer.

    Byte* src

    The source buffer.

    Int32 srcLength

    The number of chars to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    Copy(Byte*, out Int32, Int32, Char*, Int32)

    Copies a buffer of UCS-2 text. The copy is encoded as UTF-8.

    Declaration
    public static CopyError Copy(byte *dest, out int destLength, int destUTF8MaxLengthInBytes, char *src, int srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer for writing UTF-8.

    Int32 destLength

    Outputs the number of bytes written to the destination.

    Int32 destUTF8MaxLengthInBytes

    The max number of bytes that will be written to the destination buffer.

    Char* src

    The source buffer for reading UCS-2.

    Int32 srcLength

    The number of chars to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UCS-2.

    Copy(Byte*, out UInt16, UInt16, Byte*, UInt16)

    Copies a buffer of UCS-8 text.

    Declaration
    public static CopyError Copy(byte *dest, out ushort destLength, ushort destUTF8MaxLengthInBytes, byte *src, ushort srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer.

    UInt16 destLength

    Outputs the number of bytes written to the destination.

    UInt16 destUTF8MaxLengthInBytes

    The max number of bytes that will be written to the destination buffer.

    Byte* src

    The source buffer.

    UInt16 srcLength

    The number of chars to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    Copy(Byte*, out UInt16, UInt16, Char*, Int32)

    Copies a buffer of UCS-2 text. The copy is encoded as UTF-8.

    Declaration
    public static CopyError Copy(byte *dest, out ushort destLength, ushort destUTF8MaxLengthInBytes, char *src, int srcLength)
    Parameters
    Type Name Description
    Byte* dest

    The destination buffer for writing UTF-8.

    UInt16 destLength

    Outputs the number of bytes written to the destination.

    UInt16 destUTF8MaxLengthInBytes

    The max number of bytes that will be written to the destination buffer.

    Char* src

    The source buffer for reading UCS-2.

    Int32 srcLength

    The number of chars to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UCS-2.

    Copy(Char*, out Int32, Int32, Byte*, Int32)

    Copies a buffer of UTF-8 text. The copy is encoded as UCS-2.

    Declaration
    public static CopyError Copy(char *dest, out int destLength, int destUCS2MaxLengthInChars, byte *src, int srcLength)
    Parameters
    Type Name Description
    Char* dest

    The destination buffer for writing UCS-2.

    Int32 destLength

    Outputs the number of chars written to the destination.

    Int32 destUCS2MaxLengthInChars

    The max number of chars that will be written to the destination buffer.

    Byte* src

    The source buffer for reading UTF-8.

    Int32 srcLength

    The number of bytes to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    Copy(Char*, out UInt16, UInt16, Byte*, UInt16)

    Copies a buffer of UTF-8 text. The copy is encoded as UCS-2.

    Declaration
    public static CopyError Copy(char *dest, out ushort destLength, ushort destUCS2MaxLengthInChars, byte *src, ushort srcLength)
    Parameters
    Type Name Description
    Char* dest

    The destination buffer for writing UCS-2.

    UInt16 destLength

    Outputs the number of chars written to the destination.

    UInt16 destUCS2MaxLengthInChars

    The max number of chars that will be written to the destination buffer.

    Byte* src

    The source buffer for reading UTF-8.

    UInt16 srcLength

    The number of bytes to read from the source.

    Returns
    Type Description
    CopyError

    None if the copy fully completes. Otherwise, returns Truncation.

    Remarks

    Assumes the source data is valid UTF-8.

    EqualsUTF8Bytes(Byte*, Int32, Byte*, Int32)

    Returns true if two UTF-8 buffers have the same length and content.

    Declaration
    public static bool EqualsUTF8Bytes(byte *aBytes, int aLength, byte *bBytes, int bLength)
    Parameters
    Type Name Description
    Byte* aBytes

    The first buffer of UTF-8 text.

    Int32 aLength

    The length in bytes of the first buffer.

    Byte* bBytes

    The second buffer of UTF-8 text.

    Int32 bLength

    The length in bytes of the second buffer.

    Returns
    Type Description
    Boolean

    True if the content of both strings is identical.

    StrCmp(Byte*, Int32, Byte*, Int32)

    Compares two UTF-8 buffers for relative equality.

    Declaration
    public static int StrCmp(byte *utf8BufferA, int utf8LengthInBytesA, byte *utf8BufferB, int utf8LengthInBytesB)
    Parameters
    Type Name Description
    Byte* utf8BufferA

    The first buffer of UTF-8 text.

    Int32 utf8LengthInBytesA

    The length in bytes of the first UTF-8 buffer.

    Byte* utf8BufferB

    The second buffer of UTF-8 text.

    Int32 utf8LengthInBytesB

    The length in bytes of the second UTF-8 buffer.

    Returns
    Type Description
    Int32

    Less than zero if first different code point is less in the first UTF-8 buffer. Zero if the strings are identical. More than zero if first different code point is less in the second UTF-8 buffer.

    StrCmp(Byte*, Int32, Char*, Int32)

    Compares a UTF-8 buffer and a UTF-16 buffer for relative equality.

    Declaration
    public static int StrCmp(byte *utf8Buffer, int utf8LengthInBytes, char *utf16Buffer, int utf16LengthInChars)
    Parameters
    Type Name Description
    Byte* utf8Buffer

    The buffer of UTF-8 text.

    Int32 utf8LengthInBytes

    The length in bytes of the UTF-8 buffer.

    Char* utf16Buffer

    The buffer of UTF-16 text.

    Int32 utf16LengthInChars

    The length in chars of the UTF-16 buffer.

    Returns
    Type Description
    Int32

    Less than zero if first different code point is less in UTF-8 buffer. Zero if the strings are identical. More than zero if first different code point is less in UTF-16 buffer.

    StrCmp(Char*, Int32, Byte*, Int32)

    Compares a UTF-16 buffer and a UTF-8 buffer for relative equality.

    Declaration
    public static int StrCmp(char *utf16Buffer, int utf16LengthInChars, byte *utf8Buffer, int utf8LengthInBytes)
    Parameters
    Type Name Description
    Char* utf16Buffer

    The buffer of UTF-16 text.

    Int32 utf16LengthInChars

    The length in chars of the UTF-16 buffer.

    Byte* utf8Buffer

    The buffer of UTF-8 text.

    Int32 utf8LengthInBytes

    The length in bytes of the UTF-8 buffer.

    Returns
    Type Description
    Int32

    Less than zero if first different code point is less in UTF-16 buffer. Zero if the strings are identical. More than zero if first different code point is less in UTF-8 buffer.

    StrCmp(Char*, Int32, Char*, Int32)

    Compares two UTF-16 buffers for relative equality.

    Declaration
    public static int StrCmp(char *utf16BufferA, int utf16LengthInCharsA, char *utf16BufferB, int utf16LengthInCharsB)
    Parameters
    Type Name Description
    Char* utf16BufferA

    The first buffer of UTF-16 text.

    Int32 utf16LengthInCharsA

    The length in chars of the first UTF-16 buffer.

    Char* utf16BufferB

    The second buffer of UTF-16 text.

    Int32 utf16LengthInCharsB

    The length in chars of the second UTF-16 buffer.

    Returns
    Type Description
    Int32

    Less than zero if first different code point is less in the first UTF-16 buffer. Zero if the strings are identical. More than zero if first different code point is less in the second UTF-16 buffer.

    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Tuesday, June 14, 2022
    Terms of use