Arbitrary string to DBus path
Nicolas.Cavallari at lri.fr
Mon Nov 18 08:48:45 PST 2013
On 18/11/2013 17:23, Simon McVittie wrote:
> This algorithm is optimal for strings that are already very close to
> being valid object path components (or equivalently, C identifiers,
> hence the name we used). It's highly inefficient (3 times as long as
> UTF-8) for non-ASCII text: picking a random example, 日本 (Japan in
> Japanese, according to Wikipedia) comes out as _e6_97_a5_e6_9c_ac, which
> is neither short nor human-readable.
I remember having the same problem (having a unique dbus path component from an arbitrary
string), but the algorithm i used was more efficient: It was basically Bootstring (defined
as part of RFC 3492) with suitable parameters so that the result is a valid D-Bus path.
The RFC even has a C implementation (but for a different set of parameters).
This algorithm is more efficient than encoding as hexadecimal, and isn't that complex to
encode (or even decode, if really needed). It is, however, not human friendly.
More information about the dbus