mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-01-11 20:10:30 +00:00
Some checks failed
Canary release job / Create tag (push) Has been cancelled
Canary release job / Release for linux-arm64 (push) Has been cancelled
Canary release job / Release for linux-x64 (push) Has been cancelled
Canary release job / Release for win-arm64 (push) Has been cancelled
Canary release job / Release for win-x64 (push) Has been cancelled
Canary release job / Release MacOS universal (push) Has been cancelled
See merge request ryubing/ryujinx!44
42 lines
1,023 B
C#
42 lines
1,023 B
C#
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace Ryujinx.Common.GraphicsDriver.NVAPI
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
|
public unsafe struct NvapiUnicodeString
|
|
{
|
|
private fixed byte _data[4096];
|
|
|
|
public NvapiUnicodeString(string text)
|
|
{
|
|
Set(text);
|
|
}
|
|
|
|
public readonly string Get()
|
|
{
|
|
fixed (byte* data = _data)
|
|
{
|
|
string text = Encoding.Unicode.GetString(data, 4096);
|
|
|
|
int index = text.IndexOf('\0');
|
|
if (index > -1)
|
|
{
|
|
text = text[..index];
|
|
}
|
|
|
|
return text;
|
|
}
|
|
}
|
|
|
|
public readonly void Set(string text)
|
|
{
|
|
text += '\0';
|
|
fixed (char* textPtr = text)
|
|
fixed (byte* data = _data)
|
|
{
|
|
int written = Encoding.Unicode.GetBytes(textPtr, text.Length, data, 4096);
|
|
}
|
|
}
|
|
}
|
|
}
|