diff options
| author | emmauss <emmausssss@gmail.com> | 2018-08-14 03:13:01 +0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-08-13 21:13:01 -0300 |
| commit | 17f54b5d78ac9ee83419dc204a02e3887bdca8e4 (patch) | |
| tree | 76b922c31f620661b541465ba72d10ef049830dd /Ryujinx.HLE/OsHle/Utilities | |
| parent | 4f499b6845f7f46542cde945bad8f3275d3a11d5 (diff) | |
Implement IProfile Get and GetBase (#266)
* implement IProfile Get(Base)
* use default user
* changed userid
Diffstat (limited to 'Ryujinx.HLE/OsHle/Utilities')
| -rw-r--r-- | Ryujinx.HLE/OsHle/Utilities/StringUtils.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Ryujinx.HLE/OsHle/Utilities/StringUtils.cs b/Ryujinx.HLE/OsHle/Utilities/StringUtils.cs new file mode 100644 index 00000000..b0117f83 --- /dev/null +++ b/Ryujinx.HLE/OsHle/Utilities/StringUtils.cs @@ -0,0 +1,52 @@ +using System; +using System.Globalization; +using System.Linq; +using System.Text; + +namespace Ryujinx.HLE.OsHle.Utilities +{ + static class StringUtils + { + public static byte[] GetFixedLengthBytes(string InputString, int Size, Encoding Encoding) + { + InputString = InputString + "\0"; + + int ByteCount = Encoding.GetByteCount(InputString); + + byte[] Output = new byte[Size]; + + if (ByteCount < Size) + { + Encoding.GetBytes(InputString, 0, InputString.Length, Output, Size - ByteCount); + } + else + { + int NullSize = Encoding.GetByteCount("\0"); + + Output = Encoding.GetBytes(InputString); + + Array.Resize(ref Output, Size - NullSize); + + Output = Output.Concat(Encoding.GetBytes("\0")).ToArray(); + } + + return Output; + } + + public static byte[] HexToBytes(string HexString) + { + //Ignore last charactor if HexLength % 2 != 0 + int BytesInHex = HexString.Length / 2; + + byte[] Output = new byte[BytesInHex]; + + for (int Index = 0; Index < BytesInHex; Index++) + { + Output[Index] = byte.Parse(HexString.Substring(Index * 2, 2), + NumberStyles.HexNumber); + } + + return Output; + } + } +} |
