1
1
mirror of https://github.com/ryujinx-mirror/ryujinx.git synced 2025-04-17 14:34:05 -05:00
gdkchan 01c2b8097c
Implement NGC service (#5681)
* Implement NGC service

* Use raw byte arrays instead of string for _wordSeparators

* Silence IDE0230 for _wordSeparators

* Try to silence warning about _rangeValuesCount not being read on SparseSet

* Make AcType enum private

* Add abstract methods and one TODO that I forgot

* PR feedback

* More PR feedback

* More PR feedback
2023-09-27 19:21:26 +02:00

42 lines
1.0 KiB
C#

using System;
using System.Text;
namespace Ryujinx.Horizon.Sdk.Ngc.Detail
{
static class Utf8Util
{
public static Utf8ParseResult NormalizeFormKC(Span<byte> output, ReadOnlySpan<byte> input)
{
int length = input.IndexOf((byte)0);
if (length >= 0)
{
input = input[..length];
}
UTF8Encoding encoding = new(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
string text;
try
{
text = encoding.GetString(input);
}
catch (ArgumentException)
{
return Utf8ParseResult.InvalidCharacter;
}
string normalizedText = text.Normalize(NormalizationForm.FormKC);
int outputIndex = Encoding.UTF8.GetBytes(normalizedText, output);
if (outputIndex < output.Length)
{
output[outputIndex] = 0;
}
return Utf8ParseResult.Success;
}
}
}