mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2025-02-17 08:47:32 +00:00
![Tim Allen](/assets/img/avatar_default.png)
byuu says: New update. Most of the work today went into eliminating hiro::Image from all objects in all ports, replacing with nall::image. That took an eternity. Changelog: - fixed crashing bug when loading games [thanks endrift!!] - toggling "show status bar" option adjusts window geometry (not supposed to recenter the window, though) - button sizes improved; icon-only button icons no longer being cut off
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
|
|
|
namespace nall { namespace Decode {
|
|
|
|
//returns empty string on malformed content
|
|
inline auto URL(const string& input) -> string {
|
|
string output;
|
|
for(unsigned n = 0; n < input.size();) {
|
|
char c = input[n];
|
|
if(c >= 'A' && c <= 'Z') { output.append(c); n++; continue; }
|
|
if(c >= 'a' && c <= 'z') { output.append(c); n++; continue; }
|
|
if(c >= '0' && c <= '9') { output.append(c); n++; continue; }
|
|
if(c == '-' || c == '_' || c == '.' || c == '~') { output.append(c); n++; continue; }
|
|
if(c == '+') { output.append(' '); n++; continue; }
|
|
if(c != '%' || n + 2 >= input.size()) return "";
|
|
char hi = input[n + 1];
|
|
char lo = input[n + 2];
|
|
if(hi >= '0' && hi <= '9') hi -= '0';
|
|
else if(hi >= 'A' && hi <= 'F') hi -= 'A' - 10;
|
|
else if(hi >= 'a' && hi <= 'f') hi -= 'a' - 10;
|
|
else return "";
|
|
if(lo >= '0' && lo <= '9') lo -= '0';
|
|
else if(lo >= 'A' && lo <= 'F') lo -= 'A' - 10;
|
|
else if(lo >= 'a' && lo <= 'f') lo -= 'a' - 10;
|
|
else return "";
|
|
char byte = hi * 16 + lo;
|
|
output.append(byte);
|
|
n += 3;
|
|
}
|
|
return output;
|
|
}
|
|
|
|
}}
|