Exemplo n.º 1
0
SimpleString SimpleString::EscapeSequenceEncode() const
{
	SimpleString RetVal = *this;

	RetVal = RetVal.Replace( "\\", "\\\\" );
	RetVal = RetVal.Replace( "\"", "\\\"" );
	RetVal = RetVal.Replace( "\n", "\\n" );

	return RetVal;
}
Exemplo n.º 2
0
// Hurgh, this would look nicer if strings used Arrays so I could more easily modify them in place.
SimpleString SimpleString::URLEncode() const
{
	SimpleString RetVal = *this;

	// Encoding character
	RetVal = RetVal.Replace( "%", "%25" );

	// Reserved characters
	RetVal = RetVal.Replace( "!", "%21" );
	RetVal = RetVal.Replace( "#", "%23" );
	RetVal = RetVal.Replace( "$", "%24" );
	RetVal = RetVal.Replace( "&", "%26" );
	RetVal = RetVal.Replace( "'", "%27" );
	RetVal = RetVal.Replace( "(", "%28" );
	RetVal = RetVal.Replace( ")", "%29" );
	RetVal = RetVal.Replace( "*", "%2A" );
	RetVal = RetVal.Replace( "+", "%2B" );
	RetVal = RetVal.Replace( ",", "%2C" );
	RetVal = RetVal.Replace( "/", "%2F" );
	RetVal = RetVal.Replace( ":", "%3A" );
	RetVal = RetVal.Replace( ";", "%3B" );
	RetVal = RetVal.Replace( "=", "%3D" );
	RetVal = RetVal.Replace( "?", "%3F" );
	RetVal = RetVal.Replace( "@", "%40" );
	RetVal = RetVal.Replace( "[", "%5B" );
	RetVal = RetVal.Replace( "]", "%5D" );

	// Other common characters
	RetVal = RetVal.Replace( " ", "%20" );
	RetVal = RetVal.Replace( "\"", "%22" );
	RetVal = RetVal.Replace( "-", "%2D" );
	RetVal = RetVal.Replace( ".", "%2E" );
	RetVal = RetVal.Replace( "<", "%3C" );
	RetVal = RetVal.Replace( ">", "%3E" );
	RetVal = RetVal.Replace( "\\", "%5C" );
	RetVal = RetVal.Replace( "^", "%5E" );
	RetVal = RetVal.Replace( "_", "%5F" );
	RetVal = RetVal.Replace( "`", "%60" );
	RetVal = RetVal.Replace( "{", "%7B" );
	RetVal = RetVal.Replace( "|", "%7C" );
	RetVal = RetVal.Replace( "}", "%7D" );
	RetVal = RetVal.Replace( "~", "%7E" );

	return RetVal;
}