1 /* LBS: An LFS-inspired filesystem backup system
2 * Copyright (C) 2007 Michael Vrable
4 * Utility functions for converting various datatypes to text format (and
5 * later, for parsing them back, perhaps).
16 /* Perform URI-style escaping of a string. Bytes which cannot be represented
17 * directly are encoded in the form %xx (where "xx" is a string of two
18 * hexadecimal digits). */
19 string uri_encode(const string &in)
23 for (size_t i = 0; i < in.length(); i++) {
24 unsigned char c = in[i];
26 if (c > '%' && c <= 0x7f) {
30 sprintf(buf, "%%%02x", c);