trailing whitespace in strings

Ralph Giles giles at xiph.org
Tue Nov 21 21:24:44 EET 2006


Apologies if this has been discussed; I couldn't find the actual 
decision in the archives.

The 0.9.8 desktop entry spec says that 'Space before and after the 
equals sign should be ignored' but says nothing about trailing 
whitespace. glib, it seems, interprets this as 'trailing whitespace 
is part of a string value'.

However, this violates general practice of human-editable config files, 
where whitespace is minimally relevent. In particular, see

  https://maemo.org/bugzilla/show_bug.cgi?id=859

where at least two of us have lost developer time because our editors 
didn't indicate trailing whitespace in a .desktop string value, and it 
took a while to discover the parser thought it was meaningful.

I would further argue that having meaningful trailing whitespace isn't
especially useful. The spec defines a string type as containing 'all 
ASCII characters except for control characters' so this type can't be 
used for binary blobs. If trailing spaces in an ASCII value are required 
for by an application they can still be included using the '\s' escape 
sequence.

Therefore I would suggest changing the spec to indicate that leading 
and trailing whitespace be stripped from values, just as trailing 
whitespace (well 'space', I guess tab is a control character?) is 
current stripped from keys and leading whitespace is stripped from 
values. In the common case this will be more efficient in developer
time and removes no functionality from the design.

(On a related note, the 0.9.8 spec also says 'desktop entry files are 
encoded as lines of 8 bit characters', which conflicts with both the 
definition of the string and localestring types assuming the usual
unicode definition of 'charater'. Perhaps it should say '8 bit bytes'
or '8 bit chars'?)

 -r



More information about the xdg mailing list