Beispiel #1
0
        /// <summary>
        /// Converts bytes to a string according to the input parameters.
        /// </summary>
        /// <param name="data">Encoded data</param>
        /// <param name="generation">Generation string format</param>
        /// <param name="jp">Encoding is Japanese</param>
        /// <param name="isBigEndian">Encoding is Big Endian</param>
        /// <param name="count">Length of data to read.</param>
        /// <param name="offset">Offset to read from</param>
        /// <returns>Decoded string.</returns>
        public static string GetString(byte[] data, int generation, bool jp, bool isBigEndian, int count, int offset = 0)
        {
            if (isBigEndian)
            {
                return(generation == 3 ? StringConverter3.GetBEString3(data, offset, count) : StringConverter4.GetBEString4(data, offset, count));
            }

            return(generation switch
            {
                1 or 2 => StringConverter12.GetString1(data, offset, count, jp),
                3 => StringConverter3.GetString3(data, offset, count, jp),
                4 => StringConverter4.GetString4(data, offset, count),
                5 => GetString5(data, offset, count),
                6 => GetString6(data, offset, count),
                _ => GetString7(data, offset, count),
            });
Beispiel #2
0
        /// <summary>
        /// Converts bytes to a string according to the input parameters.
        /// </summary>
        /// <param name="data">Encoded data</param>
        /// <param name="generation">Generation string format</param>
        /// <param name="jp">Encoding is Japanese</param>
        /// <param name="bigendian">Encoding is BigEndian</param>
        /// <param name="count">Length of data to read.</param>
        /// <param name="offset">Offset to read from</param>
        /// <returns>Decoded string.</returns>
        public static string GetString(byte[] data, int generation, bool jp, bool bigendian, int count, int offset = 0)
        {
            if (bigendian)
            {
                return(generation == 3 ? StringConverter3.GetBEString3(data, offset, count) : StringConverter4.GetBEString4(data, offset, count));
            }

            switch (generation)
            {
            case 1:
            case 2: return(StringConverter12.GetString1(data, offset, count, jp));

            case 3: return(StringConverter3.GetString3(data, offset, count, jp));

            case 4: return(StringConverter4.GetString4(data, offset, count));

            case 5: return(GetString5(data, offset, count));

            case 6: return(GetString6(data, offset, count));

            default: return(GetString7(data, offset, count));
            }
        }
Beispiel #3
0
 private string GetString(int offset, int count) => StringConverter3.GetString3(Data, offset, count, Japanese);
Beispiel #4
0
 private string GetString(int Offset, int Count) => StringConverter3.GetString3(Data, Offset, Count, Japanese);