# Utf16ToUtf8(char*, int, byte*, out int, int)

> Copies UTF-16 characters from one buffer to another buffer as UTF-8.

## Definition

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

## Utf16ToUtf8(char\*, int, byte\*, int, int)

```csharp
public static ConversionError Utf16ToUtf8(char* utf16Buffer, int utf16Length, byte* utf8Buffer, out int utf8Length, int utf8Capacity)
```

### Parameters

**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): The source buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of chars to read from the source.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The destination buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Outputs the number of bytes written to the destination.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The size in bytes of the destination buffer.

### 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 copy fully completes. Otherwise, returns [ConversionError.Overflow](/engine/6000.7/script-reference/unity/collections/conversionerror/overflow.md). |

### Remarks

Assumes the source data is valid UTF-16.
