ini-parser
ini-parser copied to clipboard
Preserve Leading Spaces
I need to preserve leading spaces (not Trim) when reading (and writing) Key values.
Example: [ELIGCVG] RETCOND(1)= ;55; 5; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
Reads as ";55; 5; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;" And I need it to read as " ;55; 5; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;"
I got around this problem by creating a simple Wrap/Unwrap function ...
private string Wrap(string input) { return @"""" + input + @""""; // enclose string in " to preserve spaces }
private string Unwrap(string input) { return input.Substring(1, input.Length - 2); // trim leading and trailing " to preserve spaces }
Then to save I just use something like --> data["01"]["Regex"] = Wrap(txtRegex01.Text); and to load something like --> txtRegex01.Text = Unwrap(data["01"]["Regex"]);