bsnes/nall/encode/url.hpp
Tim Allen bd814f0358 Update to v106r59 release.
byuu says:

Changelog:

  - fixed bug in Emulator::Game::Memory::operator bool()
  - nall: renamed view<string> back to `string_view`
  - nall:: implemented `array_view`
  - Game Boy: split cartridge-specific input mappings (rumble,
    accelerometer) to their own separate ports
  - Game Boy: fixed MBC7 accelerometer x-axis
  - icarus: Game Boy, Super Famicom, Mega Drive cores output internal
    header game titles to heuristics manifests
  - higan, icarus, hiro/gtk: improve viewport geometry configuration;
    fixed higan crashing bug with XShm driver
  - higan: connect Video::poll(),update() functionality
  - hiro, ruby: several compilation / bugfixes, should get the macOS
    port compiling again, hopefully [Sintendo]
  - ruby/video/xshm: fix crashing bug on window resize
      - a bit hacky; it's throwing BadAccess Xlib warnings, but they're
        not fatal, so I am catching and ignoring them
  - bsnes: removed Application::Windows::onModalChange hook that's no
    longer needed [Screwtape]
2018-08-26 16:49:54 +10:00

28 lines
782 B
C++

#pragma once
namespace nall { namespace Encode {
inline auto URL(string_view input) -> string {
string output;
for(auto c : input) {
//unreserved characters
if(c >= 'A' && c <= 'Z') { output.append(c); continue; }
if(c >= 'a' && c <= 'z') { output.append(c); continue; }
if(c >= '0' && c <= '9') { output.append(c); continue; }
if(c == '-' || c == '_' || c == '.' || c == '~') { output.append(c); continue; }
//special characters
if(c == ' ') { output.append('+'); continue; }
//reserved characters
uint hi = (c >> 4) & 15;
uint lo = (c >> 0) & 15;
output.append('%');
output.append((char)(hi < 10 ? ('0' + hi) : ('a' + hi - 10)));
output.append((char)(lo < 10 ? ('0' + lo) : ('a' + lo - 10)));
}
return output;
}
}}