summaryrefslogtreecommitdiff
path: root/src/Format.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Format.cpp')
-rw-r--r--src/Format.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Format.cpp b/src/Format.cpp
index c290e71..f07b01d 100644
--- a/src/Format.cpp
+++ b/src/Format.cpp
@@ -9,6 +9,37 @@
#include "Format.h"
#include "graphics/Graphics.h"
+std::string format::URLEncode(std::string source)
+{
+ char * src = (char *)source.c_str();
+ char * dst = new char[(source.length()*3)+2];
+ std::fill(dst, dst+(source.length()*3)+2, 0);
+
+ char *d;
+ unsigned char *s;
+
+ for (d=dst; *d; d++) ;
+
+ for (s=(unsigned char *)src; *s; s++)
+ {
+ if ((*s>='0' && *s<='9') ||
+ (*s>='a' && *s<='z') ||
+ (*s>='A' && *s<='Z'))
+ *(d++) = *s;
+ else
+ {
+ *(d++) = '%';
+ *(d++) = hex[*s>>4];
+ *(d++) = hex[*s&15];
+ }
+ }
+ *d = 0;
+
+ std::string finalString(dst);
+ delete[] dst;
+ return finalString;
+}
+
std::string format::UnixtimeToDate(time_t unixtime, std::string dateFormat)
{
struct tm * timeData;