mirror of https://github.com/fltk/fltk
Added function fl_decode_uri(char*) to support the drag-and-drop of files to FLTK widgets
on the X11 platform (see STR#2849). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9580 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
145b44110b
commit
3c87a80279
|
@ -236,6 +236,27 @@ fl_open_uri(const char *uri, char *msg, int msglen) {
|
|||
#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__)
|
||||
|
|
Loading…
Reference in New Issue