Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private byte[] convertNameToOoTCharset(string name)
- {
- char[] userName = name.ToCharArray();
- byte[] convertedName = new byte[8];
- byte nameIndex = 0;
- foreach (byte c in Encoding.ASCII.GetBytes(userName))
- {
- byte adjustedChar = 0;
- if (c >= Encoding.ASCII.GetBytes("0")[0] && c <= Encoding.ASCII.GetBytes("9")[0])
- {
- adjustedChar = (byte)(c - Encoding.ASCII.GetBytes("0")[0]);
- }
- else if (c >= Encoding.ASCII.GetBytes("A")[0] && c <= Encoding.ASCII.GetBytes("Z")[0])
- {
- adjustedChar = (byte)(c + 0x6A);
- }
- else if (c >= Encoding.ASCII.GetBytes("a")[0] && c <= Encoding.ASCII.GetBytes("z")[0])
- {
- adjustedChar = (byte)(c + 0x64);
- }
- else if (c == Encoding.ASCII.GetBytes(".")[0])
- {
- adjustedChar = 0xEA;
- }
- else if (c == Encoding.ASCII.GetBytes("-")[0])
- {
- adjustedChar = 0xE4;
- }
- else if (c == Encoding.ASCII.GetBytes(" ")[0])
- {
- adjustedChar = 0xDF;
- }
- else
- {
- continue;
- }
- convertedName[nameIndex] = adjustedChar;
- nameIndex++;
- if (nameIndex >= 8)
- break;
- }
- for (byte i = nameIndex; i < 8; i++) {
- convertedName[i] = 0xDF;
- }
- return convertedName;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement