Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
similing4 opened this issue Jul 27, 2019 · 0 comments
Open

Comments

@similing4
Copy link

similing4 commented Jul 27, 2019

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;
			}
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant