From c3b3bb0ee3adafeb4f1503d6ecdb6f40cf6ac30b Mon Sep 17 00:00:00 2001 From: morkt Date: Fri, 6 Jul 2018 15:25:57 +0400 Subject: [PATCH] (noncolor): filenames encoding handling. --- ArcFormats/NonColor/ArcDAT.cs | 11 ++++++++++- ArcFormats/NonColor/ArcMinato.cs | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ArcFormats/NonColor/ArcDAT.cs b/ArcFormats/NonColor/ArcDAT.cs index 5ce96474..df4b68c5 100644 --- a/ArcFormats/NonColor/ArcDAT.cs +++ b/ArcFormats/NonColor/ArcDAT.cs @@ -58,6 +58,7 @@ namespace GameRes.Formats.NonColor public string Title; public ulong Hash; public string FileListName; + public bool LowCaseNames; public Scheme(string title) { @@ -70,6 +71,14 @@ namespace GameRes.Formats.NonColor { return Crc64.Compute (name, 0, name.Length); } + + public byte[] GetBytes (string name) + { + if (LowCaseNames) + return name.ToLowerShiftJis(); + else + return Encodings.cp932.GetBytes (name); + } } [Serializable] @@ -194,7 +203,7 @@ namespace GameRes.Formats.NonColor { var dict = new Dictionary(); FormatCatalog.Instance.ReadFileList (scheme.FileListName, line => { - var bytes = Encodings.cp932.GetBytes (line); // line.ToLowerShiftJis(); + var bytes = scheme.GetBytes (line); ulong hash = scheme.ComputeHash (bytes); dict[hash] = new NameRecord { Name = line, NameBytes = bytes }; }); diff --git a/ArcFormats/NonColor/ArcMinato.cs b/ArcFormats/NonColor/ArcMinato.cs index 3402d047..f0705364 100644 --- a/ArcFormats/NonColor/ArcMinato.cs +++ b/ArcFormats/NonColor/ArcMinato.cs @@ -38,7 +38,9 @@ namespace GameRes.Formats.Minato public override ulong ComputeHash (byte[] name) { - return Crc32.Compute (name, 0, name.Length); + var bytes = name.Clone() as byte[]; + bytes.ToLowerShiftJis(); + return Crc32.Compute (bytes, 0, bytes.Length); } }