Skip to content

Binary Model String Encoding #331

@AnakinRaW

Description

@AnakinRaW

Currently .DAT and .MEG are not alligned regarding how to handle strings in their constructors.
I'm not fully decided for either way but i'd like to bring the discussion up anyway.

Scenario: DataModels like KeyTableRecord (DAT) or MegFileNameTableRecord (Meg) require strings to have Single-byte/ASCII encoding. Their constructors allow to pass in a string value.

Discussion: Do we need data sanitazation for the string value, and if yes, at which place should it get applied?

Option 1 (MEG): The string parameter gets "re-encoded" within the constructor. The model also stores the original string value in a separate property.

Option 2 (DAT): The model is unaware of the encoding when holding the string value. This would require any consumer to ensure correct data. Since the binary models should be internal anyway, this is a valid option.

Btw: has this line key.Replace("\0", string.Empty); a specific purpose? strings in .NET are not zero-terminated, right?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions