当前位置: 首页>>代码示例>>C++>>正文


C++ SimpleString::Replace方法代码示例

本文整理汇总了C++中SimpleString::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleString::Replace方法的具体用法?C++ SimpleString::Replace怎么用?C++ SimpleString::Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleString的用法示例。


在下文中一共展示了SimpleString::Replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EscapeSequenceEncode

SimpleString SimpleString::EscapeSequenceEncode() const
{
	SimpleString RetVal = *this;

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

	return RetVal;
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:10,代码来源:simplestring.cpp

示例2: URLEncode

// 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;
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:46,代码来源:simplestring.cpp


注:本文中的SimpleString::Replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。