summaryrefslogtreecommitdiff
path: root/src/Format.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-28 23:20:52 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-28 23:20:52 (GMT)
commit9a42e47eb0369ddabe752c37b98ed3662a983694 (patch)
tree1a9fbc24e0bc17d41152657e2aa7606f818a52fb /src/Format.cpp
parent261c654ca0978cdc39c9670050c307fe0065fac1 (diff)
downloadpowder-9a42e47eb0369ddabe752c37b98ed3662a983694.zip
powder-9a42e47eb0369ddabe752c37b98ed3662a983694.tar.gz
Move old Lua API into another file, make the old drawin API have the old position quirk for rects, new graphics (gfx) api with drawRect, fillRect, drawTect, drawLine and textSize functions.
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;