docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UTF8ArrayUnsafeUtility

    Provides methods for copying and encoding Unicode text.

    Inheritance
    object
    UTF8ArrayUnsafeUtility
    Namespace: Unity.Collections
    Assembly: Unity.Collections.dll
    Syntax
    public static class UTF8ArrayUnsafeUtility

    Methods

    Append(byte*, ref ushort, ushort, byte*, ushort)

    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.

    ushort destLength

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

    ushort destUTF8MaxLengthInBytes

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

    byte* src

    The source buffer.

    ushort 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 ushort, ushort, char*, int)

    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.

    ushort destLength

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

    ushort destUTF8MaxLengthInBytes

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

    char* src

    The source buffer.

    int 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 ushort, ushort, byte*, ushort)

    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.

    ushort destLength

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

    ushort destUCS2MaxLengthInChars

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

    byte* src

    The source buffer.

    ushort 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 int, int, byte*, int)

    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.

    int destLength

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

    int destCapacity

    The destination buffer capacity in bytes.

    byte* src

    The source buffer.

    int 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 int, int, byte*, int)

    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.

    int destLength

    Outputs the number of bytes written to the destination.

    int destUTF8MaxLengthInBytes

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

    byte* src

    The source buffer.

    int 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 int, int, char*, int)

    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.

    int destLength

    Outputs the number of bytes written to the destination.

    int destUTF8MaxLengthInBytes

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

    char* src

    The source buffer for reading UCS-2.

    int 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 ushort, ushort, byte*, ushort)

    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.

    ushort destLength

    Outputs the number of bytes written to the destination.

    ushort destUTF8MaxLengthInBytes

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

    byte* src

    The source buffer.

    ushort 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 ushort, ushort, char*, int)

    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.

    ushort destLength

    Outputs the number of bytes written to the destination.

    ushort destUTF8MaxLengthInBytes

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

    char* src

    The source buffer for reading UCS-2.

    int 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 int, int, byte*, int)

    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.

    int destLength

    Outputs the number of chars written to the destination.

    int destUCS2MaxLengthInChars

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

    byte* src

    The source buffer for reading UTF-8.

    int 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 ushort, ushort, byte*, ushort)

    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.

    ushort destLength

    Outputs the number of chars written to the destination.

    ushort destUCS2MaxLengthInChars

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

    byte* src

    The source buffer for reading UTF-8.

    ushort 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*, int, byte*, int)

    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.

    int aLength

    The length in bytes of the first buffer.

    byte* bBytes

    The second buffer of UTF-8 text.

    int bLength

    The length in bytes of the second buffer.

    Returns
    Type Description
    bool

    True if the content of both strings is identical.

    StrCmp(byte*, int, byte*, int)

    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.

    int utf8LengthInBytesA

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

    byte* utf8BufferB

    The second buffer of UTF-8 text.

    int utf8LengthInBytesB

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

    Returns
    Type Description
    int

    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*, int, char*, int)

    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.

    int utf8LengthInBytes

    The length in bytes of the UTF-8 buffer.

    char* utf16Buffer

    The buffer of UTF-16 text.

    int utf16LengthInChars

    The length in chars of the UTF-16 buffer.

    Returns
    Type Description
    int

    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*, int, byte*, int)

    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.

    int utf16LengthInChars

    The length in chars of the UTF-16 buffer.

    byte* utf8Buffer

    The buffer of UTF-8 text.

    int utf8LengthInBytes

    The length in bytes of the UTF-8 buffer.

    Returns
    Type Description
    int

    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*, int, char*, int)

    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.

    int utf16LengthInCharsA

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

    char* utf16BufferB

    The second buffer of UTF-16 text.

    int utf16LengthInCharsB

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

    Returns
    Type Description
    int

    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.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)