mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-trx.git
				synced 2025-11-03 21:53:18 +00:00 
			
		
		
		
	git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@5655 19bc5d8c-e614-43d4-8b26-e1612bc8e597
		
			
				
	
	
		
			29 lines
		
	
	
		
			546 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			546 B
		
	
	
	
		
			C++
		
	
	
	
	
	
/* Copyright 2011, Range Networks, Inc. */
 | 
						|
 | 
						|
#include <URLEncode.h>
 | 
						|
#include <string>
 | 
						|
#include <string.h>
 | 
						|
#include <ctype.h>
 | 
						|
 | 
						|
using namespace std;
 | 
						|
 | 
						|
//based on javascript encodeURIComponent()
 | 
						|
string URLEncode(const string &c)
 | 
						|
{
 | 
						|
	static const char *digits = "01234567890ABCDEF";
 | 
						|
	string retVal="";
 | 
						|
	for (size_t i=0; i<c.length(); i++)
 | 
						|
	{
 | 
						|
		const char ch = c[i];
 | 
						|
		if (isalnum(ch) || strchr("-_.!~'()",ch)) {
 | 
						|
			retVal += ch;
 | 
						|
		} else {
 | 
						|
			retVal += '%';
 | 
						|
			retVal += digits[(ch>>4) & 0x0f];
 | 
						|
			retVal += digits[ch & 0x0f];
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return retVal;
 | 
						|
}
 | 
						|
 |