本文整理汇总了C++中nsCString::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::Replace方法的具体用法?C++ nsCString::Replace怎么用?C++ nsCString::Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::Replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/**
* Decodes the given base64 string.
*
* It returns its decoded string in its input.
*
* @param pBufInOut (inout) a buffer of the string
*/
void nsMsgBodyHandler::Base64Decode (nsCString &pBufInOut)
{
char *decodedBody = PL_Base64Decode(pBufInOut.get(), pBufInOut.Length(), nullptr);
if (decodedBody)
pBufInOut.Adopt(decodedBody);
int32_t offset = pBufInOut.FindChar('\n');
while (offset != -1) {
pBufInOut.Replace(offset, 1, ' ');
offset = pBufInOut.FindChar('\n', offset);
}
offset = pBufInOut.FindChar('\r');
while (offset != -1) {
pBufInOut.Replace(offset, 1, ' ');
offset = pBufInOut.FindChar('\r', offset);
}
}
示例2: while
// convert '"' to """
static void
rdf_EscapeQuotes(nsCString& s)
{
int32_t i = 0;
while ((i = s.FindChar('"', i)) != -1) {
s.Replace(i, 1, quot, sizeof(quot) - 1);
i += sizeof(quot) - 2;
}
}
示例3: nsParseImapMessageURI
/* parses ImapMessageURI */
nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key, char **part)
{
if(!key)
return NS_ERROR_NULL_POINTER;
nsCAutoString uriStr(uri);
PRInt32 folderEnd = -1;
// imap-message uri's can have imap:// url strings tacked on the end,
// e.g., when opening/saving attachments. We don't want to look for '#'
// in that part of the uri, if the attachment name contains '#',
// so check for that here.
if (StringBeginsWith(uriStr, NS_LITERAL_CSTRING("imap-message")))
folderEnd = uriStr.Find("imap://");
PRInt32 keySeparator = MsgRFindChar(uriStr, '#', folderEnd);
if(keySeparator != -1)
{
PRInt32 keyEndSeparator = MsgFindCharInSet(uriStr, "/?&", keySeparator);
nsAutoString folderPath;
folderURI = StringHead(uriStr, keySeparator);
folderURI.Cut(4, 8); // cut out the _message part of imap-message:
// folder uri's don't have fully escaped usernames.
PRInt32 atPos = folderURI.FindChar('@');
if (atPos != -1)
{
nsCString unescapedName, escapedName;
PRInt32 userNamePos = folderURI.Find("//") + 2;
PRUint32 origUserNameLen = atPos - userNamePos;
if (NS_SUCCEEDED(MsgUnescapeString(Substring(folderURI, userNamePos,
origUserNameLen),
0, unescapedName)))
{
// Re-escape the username, matching the way we do it in uris, not the
// way necko escapes urls. See nsMsgIncomingServer::GetServerURI.
MsgEscapeString(unescapedName, nsINetUtil::ESCAPE_XALPHAS, escapedName);
folderURI.Replace(userNamePos, origUserNameLen, escapedName);
}
}
nsCAutoString keyStr;
if (keyEndSeparator != -1)
keyStr = Substring(uriStr, keySeparator + 1, keyEndSeparator - (keySeparator + 1));
else
keyStr = Substring(uriStr, keySeparator + 1);
*key = strtoul(keyStr.get(), nsnull, 10);
if (part && keyEndSeparator != -1)
{
PRInt32 partPos = MsgFind(uriStr, "part=", PR_FALSE, keyEndSeparator);
if (partPos != -1)
{
*part = ToNewCString(Substring(uriStr, keyEndSeparator));
}
}
}
return NS_OK;
}
示例4: CleanUpIcalString
static
void CleanUpIcalString(nsCString & data) {
//remove all '\r\n '
PRInt32 pos = -1;
while ((pos = data.Find("\r\n ")) >= 0) {
data.Cut(pos, 3);
}
char src[512] = {0};
char dst[512] = {0};
//Update TZID,
//the exchange will use tz name some times update to TZID
for(size_t i=0;i < TIMEZONES_COUNT; i+=2) {
sprintf(src, "TZID:%s", TIMEZONES[i]);
sprintf(dst, "TZID:%s", TIMEZONES[i + 1]);
while((pos = data.Find(src)) >= 0) {
data.Replace(pos,
strlen(src),
dst,
strlen(dst));
}
sprintf(src, "TZID=\"%s\"", TIMEZONES[i]);
sprintf(dst, "TZID=\"%s\"", TIMEZONES[i + 1]);
while((pos = data.Find(src)) >= 0) {
data.Replace(pos,
strlen(src),
dst,
strlen(dst));
}
}
}
示例5: ReplaceChar
static void ReplaceChar(nsCString& str, const nsACString& character,
const nsACString& replacement)
{
nsCString::const_iterator start, end;
str.BeginReading(start);
str.EndReading(end);
while (FindInReadable(character, start, end)) {
PRInt32 pos = end.size_backward();
str.Replace(pos - 1, 1, replacement);
str.BeginReading(start);
start.advance(pos + replacement.Length() - 1);
str.EndReading(end);
}
}