ini-parser icon indicating copy to clipboard operation
ini-parser copied to clipboard

Preserve Leading Spaces

Open MusashiBugs opened this issue 6 years ago • 1 comments

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; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;"

MusashiBugs avatar Jan 04 '19 13:01 MusashiBugs

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"]);

TheSnyper avatar Feb 07 '21 10:02 TheSnyper