I am storing some short user data strings in the Windows registry. This worked fine until one of my users tried to store a string containing a ‘\’ character. This was then interpreted as a registry path delimiter.
What is the best practice for avoiding this problem? Some sort of simple encoding?
Note/ I am using the Qt QSetting class to access the registry via C++, so I would appreciate an answer that is generic, rather than specific to any particular MS tool/language.
You should be able to use the
QSettings::setValue()function directly. If that does not work (for the value, not the key name) then that sounds like a bug in Qt. The section on Key Syntax does explicitly mention that slashes should not be used for key names, but don’t see what would be wrong with values.