GNOME Bugzilla – Bug 547175
Allow escaping of the comment character in g_key_file_*
Last modified: 2008-08-11 17:00:10 UTC
It would be nice if the comment character in key value file could be escaped with a backslash to be able to use it in keys and in values. Currently, something like: [somegroup] foo=b\#ar doesn't work, the key 'foo' is ignored because of the '#' character. It would be nice if GLib would recognise the backslash character and allow the '#' char.
That shouldn't be necessary. According to the desktop entry spec, # should only have special significance at the beginning of a line. foo=b\#ar doesn't work because \# is not a supported escape sequence. I'd be surprised if foo=b#ar doesn't work. If it doesn't, I'd appreciate a patch that adds a testcase for that to glib/tests/keyfile.c
For some reason, it didn't work for me without escaping before I reported this. But I tested it again and it works fine with an hash character in a key and/or in a value. So there is actually no need to change this. The only thing is that you can't define keys which start with an hash character as it is (correctly) recognised as the comment character. I guess use cases for keys starting an hash character are rare and so there is maybe no real need to make the comment character escapable.
From the desktop entry spec: Key names must contain only the characters A-Za-z0-9-.
Ok, great. GLib does what it should and it does not what it should not. Thanks for clarification.