Author: manolo
Date: 2012-06-10 02:24:33 -0700 (Sun, 10 Jun 2012)
New Revision: 9580
Log:
Added function fl_decode_uri(char*) to support the drag-and-drop of files to
FLTK widgets
on the X11 platform (see STR#2849).
Modified:
branches/branch-1.3/src/fl_open_uri.cxx
Modified: branches/branch-1.3/src/fl_open_uri.cxx
===================================================================
--- branches/branch-1.3/src/fl_open_uri.cxx 2012-06-09 21:49:26 UTC (rev
9579)
+++ branches/branch-1.3/src/fl_open_uri.cxx 2012-06-10 09:24:33 UTC (rev
9580)
@@ -236,6 +236,27 @@
#endif // WIN32
}
+/** Decodes a URL-encoded string.
+
+ In a Uniform Resource Identifier (URI), all non-ASCII bytes and several
others (e.g., '<', '%', ' ')
+ are URL-encoded using 3 bytes by "%XY" where XY is the hexadecimal value of
the byte. This function
+ decodes the URI restoring its original UTF-8 encoded content. Decoding is
done in-place.
+ */
+void fl_decode_uri(char *uri)
+{
+ char *last = uri + strlen(uri);
+ while (uri < last-2) {
+ if (*uri == '%') {
+ int h;
+ if ( sscanf(uri+1, "%2X", &h) != 1 ) break;
+ *uri = h;
+ memmove(uri+1, uri+3, last - (uri+2));
+ last -= 2;
+ }
+ uri++;
+ }
+}
+
/** @} */
#if !defined(WIN32) && !defined(__APPLE__)
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit