c++ - Encode URLs into safe filename string -
i'm writing simple c++ class in cache picture thumbnails versions of images downloaded web. such, use hash function takes in url strings , outputs unique string suitable filename.
is there simple way without re-writing function myself? searched around simple library, couldn't find anything. surely common problem.
a simpler approach replace not character or number underscore.
edit: here's naive implementation in c:
#include <cctype> char *safe_url(const char *str) { char *safe = strdup(str); (int = 0; < strlen(str); i++) { if (isalpha(str[i])) safe[i] = str[i]; else safe[i] = '_'; } }
Comments
Post a Comment