Struct UnsafeText
An unmanaged, mutable, resizable UTF-8 string.
Namespace: Unity.Collections.LowLevel.Unsafe
Syntax
public struct UnsafeText : INativeDisposable, IDisposable, IUTF8Bytes, INativeList<byte>, IIndexable<byte>
Remarks
The string is always null-terminated, meaning a zero byte always immediately follows the last character.
Constructors
UnsafeText(Int32, AllocatorManager.AllocatorHandle)
Initializes and returns an instance of UnsafeText.
Declaration
public UnsafeText(int capacity, AllocatorManager.AllocatorHandle allocator)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | The initial capacity, in bytes. |
AllocatorManager.AllocatorHandle | allocator | The allocator to use. |
Properties
Capacity
The current capacity in bytes of this string.
Declaration
public int Capacity { readonly get; set; }
Property Value
Type | Description |
---|---|
Int32 | The current capacity in bytes of the string. |
Implements
Remarks
The null-terminator byte is not included in the capacity, so the string's character buffer is Capacity + 1
in size.
IsCreated
Whether this string's character buffer has been allocated (and not yet deallocated).
Declaration
public readonly bool IsCreated { get; }
Property Value
Type | Description |
---|---|
Boolean | Whether this string's character buffer has been allocated (and not yet deallocated). |
IsEmpty
Reports whether container is empty.
Declaration
public readonly bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean | True if the string is empty or the string has not been constructed. |
Implements
Item[Int32]
The byte at an index.
Declaration
public byte this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | A zero-based byte index. |
Property Value
Type | Description |
---|---|
Byte | The byte at the index. |