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
    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)