aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Account/Nickname.cs
blob: 1f351ee3a4489f6f84e1db7d029495dffba76482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Ryujinx.Common.Memory;
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Ryujinx.Horizon.Sdk.Account
{
    [StructLayout(LayoutKind.Sequential, Size = 0x21, Pack = 0x1)]
    readonly struct Nickname
    {
        public readonly Array33<byte> Name;

        public Nickname(in Array33<byte> name)
        {
            Name = name;
        }

        public override string ToString()
        {
            int length = ((ReadOnlySpan<byte>)Name.AsSpan()).IndexOf((byte)0);
            if (length < 0)
            {
                length = 33;
            }

            return Encoding.UTF8.GetString(Name.AsSpan()[..length]);
        }
    }
}