diff --git a/GameRes/Utility.cs b/GameRes/Utility.cs index e344d42e..d1a37f73 100644 --- a/GameRes/Utility.cs +++ b/GameRes/Utility.cs @@ -24,6 +24,7 @@ // using System.IO; +using System.Text; namespace GameRes.Utility { @@ -83,6 +84,19 @@ namespace GameRes.Utility count -= preceding; } } + + public static string GetCString (byte[] data, int index, int length_limit, Encoding enc) + { + int name_length = 0; + while (name_length < length_limit && 0 != data[index+name_length]) + name_length++; + return enc.GetString (data, index, name_length); + } + + public static string GetCString (byte[] data, int index, int length_limit) + { + return GetCString (data, index, length_limit, Encodings.cp932); + } } public static class BigEndian