# StrCmp

> Compares two UTF-8 buffers for relative equality.

## Definition

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

## StrCmp(byte\*, int, byte\*, int)

Compares two UTF-8 buffers for relative equality.

```csharp
public static int StrCmp(byte* utf8BufferA, int utf8LengthInBytesA, byte* utf8BufferB, int utf8LengthInBytesB)
```

### Parameters

**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The first buffer of UTF-8 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in bytes of the first UTF-8 buffer.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The second buffer of UTF-8 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in bytes of the second UTF-8 buffer.

### Returns

| Type                                                       | Description                                                                                                                                                                                         |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Less than zero if first different code point is less in the first UTF-8 buffer. Zero if the strings are identical. More than zero if first different code point is less in the second UTF-8 buffer. |

## StrCmp(char\*, int, char\*, int)

Compares two UTF-16 buffers for relative equality.

```csharp
public static int StrCmp(char* utf16BufferA, int utf16LengthInCharsA, char* utf16BufferB, int utf16LengthInCharsB)
```

### Parameters

**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): The first buffer of UTF-16 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in chars of the first UTF-16 buffer.**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): The second buffer of UTF-16 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in chars of the second UTF-16 buffer.

### Returns

| Type                                                       | Description                                                                                                                                                                                           |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Less than zero if first different code point is less in the first UTF-16 buffer. Zero if the strings are identical. More than zero if first different code point is less in the second UTF-16 buffer. |

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

Compares a UTF-8 buffer and a UTF-16 buffer for relative equality.

```csharp
public static int StrCmp(byte* utf8Buffer, int utf8LengthInBytes, char* utf16Buffer, int utf16LengthInChars)
```

### Parameters

**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The buffer of UTF-8 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in bytes of the UTF-8 buffer.**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): The buffer of UTF-16 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in chars of the UTF-16 buffer.

### Returns

| Type                                                       | Description                                                                                                                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Less than zero if first different code point is less in UTF-8 buffer. Zero if the strings are identical. More than zero if first different code point is less in UTF-16 buffer. |

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

Compares a UTF-16 buffer and a UTF-8 buffer for relative equality.

```csharp
public static int StrCmp(char* utf16Buffer, int utf16LengthInChars, byte* utf8Buffer, int utf8LengthInBytes)
```

### Parameters

**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): The buffer of UTF-16 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in chars of the UTF-16 buffer.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): The buffer of UTF-8 text.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The length in bytes of the UTF-8 buffer.

### Returns

| Type                                                       | Description                                                                                                                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Less than zero if first different code point is less in UTF-16 buffer. Zero if the strings are identical. More than zero if first different code point is less in UTF-8 buffer. |
