# UnsafeText

> An unmanaged, mutable, resizable UTF-8 string.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections.LowLevel.Unsafe](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable), [IUTF8Bytes](/engine/6000.7/script-reference/unity/collections/iutf8bytes.md), [INativeList\<byte>](/engine/6000.7/script-reference/unity/collections/inativelist1.md), [IIndexable\<byte>](/engine/6000.7/script-reference/unity/collections/iindexable1.md)

```csharp
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.

## Static Fields

| Value                                                                                                      | Description                                                     |
| ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [MaxCapacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/maxcapacity.md) | The maximum number of elements this type of container can hold. |

## Constructors

| Constructor                                                                                                                                                         | Description                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [UnsafeText(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/ctor.md) | Initializes and returns an instance of UnsafeText. |

## Properties

| Property                                                                                               | Description                                                                          |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| [Capacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/capacity.md)   | The current capacity in bytes of this string.                                        |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/iscreated.md) | Whether this string's character buffer has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/isempty.md)     | Reports whether container is empty.                                                  |
| [this\[\]](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/item.md)       | The byte at an index.                                                                |
| [Length](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/length.md)       | The current length in bytes of this string.                                          |

## Methods

| Method                                                                                                       | Description                                                  |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
| [Clear](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/clear.md)               | Sets the length to 0.                                        |
| [Dispose](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/dispose.md)           | Releases all resources (memory).                             |
| [ElementAt](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/elementat.md)       | Returns a reference to the byte (not character) at an index. |
| [GetUnsafePtr](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/getunsafeptr.md) | Returns a pointer to this string's character buffer.         |
| [ToString](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/tostring.md)         | Returns a managed string copy of this string.                |
| [TryResize](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafetext/tryresize.md)       | Attempt to set the length in bytes of this string.           |
