3
Vote

Exception on calling GetTag

description

Index was outside the bounds of the array.

at System.String.get_Chars(Int32 index)
at Id3.Internal.TextEncodingHelper.GetString(Byte[] bytes, Int32 start, Int32 count, Id3TextEncoding encodingType)
at Id3.Internal.TextEncodingHelper.GetSplitStrings(Byte[] bytes, Int32 start, Int32 count, Id3TextEncoding encodingType)
at Id3.Frames.CommentFrame.Decode(Byte[] data)
at Id3.Id3v2.v23.Id3v23Handler.ReadTag(Stream stream)
at Id3.Mp3Stream.GetAllTags()

comments

vanomaisuradze wrote Aug 5, 2013 at 7:01 AM

This bug is in TextEncodingHelper.cs file (in GetString function).

I changed it for myself ('str' was causing this exception):

internal static string GetString(byte[] bytes, int start, int count, Id3TextEncoding encodingType)
    {
        Encoding encoding = GetEncoding(encodingType);
        string str = encoding.GetString(bytes, start, count);

        if (str.Length > 0 && encodingType == Id3TextEncoding.Unicode)
        {
            if (str[0] == '\xFFFE' || str[0] == '\xFEFF')
                str = str.Remove(0, 1);
        }

        return str;
    }

wrote Sep 12, 2013 at 2:18 AM