# UcsToUtf8(byte*, ref int, int, Rune)

> Writes a rune to a buffer as a UTF-8 encoded character.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## UcsToUtf8(byte\*, int, int, Rune)

```csharp
public static ConversionError UcsToUtf8(byte* buffer, ref int index, int capacity, Unicode.Rune rune)
```

### Parameters

**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The buffer to write to.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Reference to a byte index into the buffer. If the write succeeds, index is incremented by the size in bytes of the character written. If the write fails, index is not incremented.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The size in bytes of the buffer. Used to check that the write is in bounds.**** (\[Rune]\(/engine/6000.7/script-reference/unity/collections/unicode/rune)): The rune to encode.

### Returns

| Type                                                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ConversionError](/engine/6000.7/script-reference/unity/collections/conversionerror.md) | [ConversionError.None](/engine/6000.7/script-reference/unity/collections/conversionerror/none.md) if the write succeeds. Otherwise, returns [ConversionError.CodePoint](/engine/6000.7/script-reference/unity/collections/conversionerror/codepoint.md), [ConversionError.Overflow](/engine/6000.7/script-reference/unity/collections/conversionerror/overflow.md), or [ConversionError.Encoding](/engine/6000.7/script-reference/unity/collections/conversionerror/encoding.md). |
