Fixed some encoding errors.

This commit is contained in:
Max
2021-05-04 19:45:00 -05:00
parent 32399a692c
commit 2e02c2e7ef
5 changed files with 25 additions and 7 deletions

View File

@ -158,10 +158,8 @@ namespace RobloxFiles
internal void WriteString(string value)
{
int length = value.Length;
Writer.Write(length);
byte[] utf8 = Encoding.UTF8.GetBytes(value);
Writer.Write(utf8.Length);
Writer.Write(utf8);
}
@ -239,6 +237,10 @@ namespace RobloxFiles
}
}
public Attributes() : base()
{
}
internal Attributes(BinaryReader reader)
{
Initialize(reader);

View File

@ -64,7 +64,7 @@ namespace RobloxFiles
public HashSet<string> Tags { get; } = new HashSet<string>();
/// <summary>The attributes defined for this Instance.</summary>
private Attributes AttributesImpl;
private Attributes AttributesImpl = new Attributes();
/// <summary>The public readonly access point of the attributes on this Instance.</summary>
public IReadOnlyDictionary<string, Attribute> Attributes => AttributesImpl;
@ -161,7 +161,9 @@ namespace RobloxFiles
if (key.Length > 100)
return false;
if (!Attribute.SupportsType<T>())
Type type = value.GetType();
if (!Attribute.SupportsType(type))
return false;
var attr = new Attribute(value);
@ -170,7 +172,6 @@ namespace RobloxFiles
return true;
}
/// <summary>Returns true if this Instance is an ancestor to the provided Instance.</summary>
/// <param name="descendant">The instance whose descendance will be tested against this Instance.</param>
public bool IsAncestorOf(Instance descendant)