Fixed unicode handling bug in NBT Strings, which could result in an inconsistent NBT binary.

This commit is contained in:
Justin Aquadro 2012-08-24 00:14:53 -04:00
parent f062f736ef
commit 613fc34df7
2 changed files with 7 additions and 7 deletions

View file

@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.3.3.0")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: AssemblyVersion("1.3.4.0")]
[assembly: AssemblyFileVersion("1.3.4.0")]
// This library is compatible with all CLS-compliant .NET programming languages.
[assembly: CLSCompliant(true)]

View file

@ -271,7 +271,7 @@ namespace Substrate.Nbt
byte[] strBytes = new byte[len];
_stream.Read(strBytes, 0, len);
System.Text.Encoding str = Encoding.GetEncoding(28591);
System.Text.Encoding str = Encoding.UTF8;
TagNodeString val = new TagNodeString(str.GetString(strBytes));
@ -496,7 +496,10 @@ namespace Substrate.Nbt
private void WriteString (TagNodeString val)
{
byte[] lenBytes = BitConverter.GetBytes((short)val.Length);
System.Text.Encoding str = Encoding.UTF8;
byte[] gzBytes = str.GetBytes(val.Data);
byte[] lenBytes = BitConverter.GetBytes((short)gzBytes.Length);
if (BitConverter.IsLittleEndian) {
Array.Reverse(lenBytes);
@ -504,9 +507,6 @@ namespace Substrate.Nbt
_stream.Write(lenBytes, 0, 2);
System.Text.Encoding str = Encoding.GetEncoding(28591);
byte[] gzBytes = str.GetBytes(val.Data);
_stream.Write(gzBytes, 0, gzBytes.Length);
}