Skip to content

There is a bug on BinaryReverseReader.cs when parsing chinese string. #12

@similing4

Description

@similing4

When the name of psd is chinese string, the ReadPascalString method of BinaryReverseReader class use "new String(c)" will be random code.
The old code is:

		public String ReadPascalString()
		{
			Byte stringLength = base.ReadByte();

			Char[] c = base.ReadChars(stringLength);

			if ((stringLength % 2) == 0) base.ReadByte();

			return new String(c);
		}

it should change to :

		public String ReadPascalString()
		{
			try
			{
				byte stringLength = base.ReadByte();
				byte[] c = base.ReadBytes(stringLength);
				if ((stringLength % 2) == 0)
					base.ReadByte();
				return Encoding.GetEncoding("GBK").GetString(c);
			}
			catch (Exception)
			{
				return string.Empty;
			}
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions