-
Notifications
You must be signed in to change notification settings - Fork 2
Description
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?