Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values containing '\' character are not parsed properly #28

Closed
RadCraftplay opened this issue Jul 15, 2020 · 2 comments
Closed

Values containing '\' character are not parsed properly #28

RadCraftplay opened this issue Jul 15, 2020 · 2 comments

Comments

@RadCraftplay
Copy link

When I try to parse text:

"Config"
{
	"Games"	"Some\text"
}

With code:

var text = "\"Config\"\n{\n    \"Games\"    \"Some\\text\"\n}";
var config = VdfConvert.Deserialize(text);
var games = config.Value["Games"];

Value "Games" is parsed as "some\text" instead of "some\\text" (if you "Console.Write" this you get "some ext").

@shravan2x
Copy link
Owner

I believe this is an error in the VDF file itself if it uses escape sequences. It should have been written as "some\\text" and would have been parsed correctly.

However, Valve's own VDF parser has an option to disable escape sequences. So it's possible some VDF files just don't support them. In this library, support for escape sequences is enabled by default, but this can be changed by setting UsesEscapeSequences to false. Or simply by using var config = VdfConvert.Deserialize(text, VdfSerializerSettings.Default);.

The naming for the two VdfSerializerSettings might seem counter-intuitive since VdfSerializerSettings.Default is actually not the default, but rather VdfSerializerSettings.Common. This is because VdfSerializerSettings.Default refers to the defaults in Valve's own VDF parser, not the defaults of this library. In my experience, it's far more common for users to encounter VDF files that use escape sequences, so the default of this library is VdfSerializerSettings.Common instead.

@RadCraftplay
Copy link
Author

Thanks for help! Problem solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants