Fix some UTF-8 encoding bugs

This commit is contained in:
Katy Coe
2017-11-10 14:09:49 +01:00
parent 8871254e1b
commit 0a0876c337
2 changed files with 4 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text;
using Il2CppInspector.Reflection; using Il2CppInspector.Reflection;
namespace Il2CppInspector namespace Il2CppInspector
@@ -17,7 +18,7 @@ namespace Il2CppInspector
} }
public void WriteFile(string outFile) { public void WriteFile(string outFile) {
using (var writer = new StreamWriter(new FileStream(outFile, FileMode.Create))) { using (var writer = new StreamWriter(new FileStream(outFile, FileMode.Create), Encoding.UTF8)) {
foreach (var asm in model.Assemblies) { foreach (var asm in model.Assemblies) {
writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.Definition.typeStart}\n"); writer.Write($"// Image {asm.Index}: {asm.FullName} - {asm.Definition.typeStart}\n");
} }

View File

@@ -58,7 +58,8 @@ namespace Il2CppInspector
value = Metadata.ReadByte(); value = Metadata.ReadByte();
break; break;
case Il2CppTypeEnum.IL2CPP_TYPE_CHAR: case Il2CppTypeEnum.IL2CPP_TYPE_CHAR:
value = Metadata.ReadChar(); // UTF-8 character assumed
value = BitConverter.ToChar(Metadata.ReadBytes(2), 0);
break; break;
case Il2CppTypeEnum.IL2CPP_TYPE_U2: case Il2CppTypeEnum.IL2CPP_TYPE_U2:
value = Metadata.ReadUInt16(); value = Metadata.ReadUInt16();