summaryrefslogtreecommitdiff
path: root/libs/pbd/convert.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-10-11 22:07:47 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-10-11 22:07:47 +0000
commitf7f9d6fdc40248b190ec9c6e1a886261d55777ae (patch)
tree080723e9dc35a66013b37acbafc67a6afa929302 /libs/pbd/convert.cc
parentaa1f736a651376534acaa2268b65d42a3786fff7 (diff)
merge from 2.0-ongoing by hand, minus key binding editor
git-svn-id: svn://localhost/ardour2/trunk@2539 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/convert.cc')
-rw-r--r--libs/pbd/convert.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc
index 07fcc09ace..2ce99ba631 100644
--- a/libs/pbd/convert.cc
+++ b/libs/pbd/convert.cc
@@ -30,6 +30,7 @@
using std::string;
using std::vector;
+using Glib::ustring;
namespace PBD {
@@ -194,6 +195,52 @@ url_decode (string& url)
}
}
+void
+url_decode (ustring& url)
+{
+ ustring::iterator last;
+ ustring::iterator next;
+
+ for (ustring::iterator i = url.begin(); i != url.end(); ++i) {
+ if ((*i) == '+') {
+ next = i;
+ ++next;
+ url.replace (i, next, 1, ' ');
+ }
+ }
+
+ if (url.length() <= 3) {
+ return;
+ }
+
+ last = url.end();
+
+ --last; /* points at last char */
+ --last; /* points at last char - 1 */
+
+ for (ustring::iterator i = url.begin(); i != last; ) {
+
+ if (*i == '%') {
+
+ next = i;
+
+ url.erase (i);
+
+ i = next;
+ ++next;
+
+ if (isxdigit (*i) && isxdigit (*next)) {
+ /* replace first digit with char */
+ url.replace (i, next, 1, (gunichar) int_from_hex (*i,*next));
+ ++i; /* points at 2nd of 2 digits */
+ url.erase (i);
+ }
+ } else {
+ ++i;
+ }
+ }
+}
+
#if 0
string
length2string (const int32_t frames, const float sample_rate)