forked from mirrors/NBTExplorer
Fixed unicode handling bug in NBT Strings, which could result in an inconsistent NBT binary.
This commit is contained in:
parent
f062f736ef
commit
613fc34df7
2 changed files with 7 additions and 7 deletions
|
@ -30,8 +30,8 @@ using System.Runtime.InteropServices;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("1.3.3.0")]
|
[assembly: AssemblyVersion("1.3.4.0")]
|
||||||
[assembly: AssemblyFileVersion("1.3.3.0")]
|
[assembly: AssemblyFileVersion("1.3.4.0")]
|
||||||
|
|
||||||
// This library is compatible with all CLS-compliant .NET programming languages.
|
// This library is compatible with all CLS-compliant .NET programming languages.
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
|
@ -271,7 +271,7 @@ namespace Substrate.Nbt
|
||||||
byte[] strBytes = new byte[len];
|
byte[] strBytes = new byte[len];
|
||||||
_stream.Read(strBytes, 0, 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));
|
TagNodeString val = new TagNodeString(str.GetString(strBytes));
|
||||||
|
|
||||||
|
@ -496,7 +496,10 @@ namespace Substrate.Nbt
|
||||||
|
|
||||||
private void WriteString (TagNodeString val)
|
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) {
|
if (BitConverter.IsLittleEndian) {
|
||||||
Array.Reverse(lenBytes);
|
Array.Reverse(lenBytes);
|
||||||
|
@ -504,9 +507,6 @@ namespace Substrate.Nbt
|
||||||
|
|
||||||
_stream.Write(lenBytes, 0, 2);
|
_stream.Write(lenBytes, 0, 2);
|
||||||
|
|
||||||
System.Text.Encoding str = Encoding.GetEncoding(28591);
|
|
||||||
byte[] gzBytes = str.GetBytes(val.Data);
|
|
||||||
|
|
||||||
_stream.Write(gzBytes, 0, gzBytes.Length);
|
_stream.Write(gzBytes, 0, gzBytes.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue