本文整理汇总了C++中nsCString::ReplaceSubstring方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::ReplaceSubstring方法的具体用法?C++ nsCString::ReplaceSubstring怎么用?C++ nsCString::ReplaceSubstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::ReplaceSubstring方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertLineBreaks
// i18n helper routines
nsresult
nsEncodingFormSubmission::EncodeVal(const nsAString& aStr, nsCString& aOut,
bool aHeaderEncode)
{
if (mEncoder && !aStr.IsEmpty()) {
aOut.Truncate();
nsresult rv = mEncoder->Convert(PromiseFlatString(aStr).get(),
getter_Copies(aOut));
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// fall back to UTF-8
CopyUTF16toUTF8(aStr, aOut);
}
if (aHeaderEncode) {
aOut.Adopt(nsLinebreakConverter::
ConvertLineBreaks(aOut.get(),
nsLinebreakConverter::eLinebreakAny,
nsLinebreakConverter::eLinebreakSpace));
aOut.ReplaceSubstring(NS_LITERAL_CSTRING("\""),
NS_LITERAL_CSTRING("\\\""));
}
return NS_OK;
}
示例2: SanitizeSampleData
void ImportAddressImpl::SanitizeSampleData( nsCString& val)
{
// remove any line-feeds...
val.ReplaceSubstring( "\x0D\x0A", ", ");
val.ReplaceChar( 13, ',');
val.ReplaceChar( 10, ',');
}
示例3: ConvertLineBreaks
// i18n helper routines
nsresult
nsEncodingFormSubmission::EncodeVal(const nsAString& aStr, nsCString& aOut,
bool aHeaderEncode)
{
if (!mEncoder.Encode(aStr, aOut)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (aHeaderEncode) {
aOut.Adopt(nsLinebreakConverter::
ConvertLineBreaks(aOut.get(),
nsLinebreakConverter::eLinebreakAny,
nsLinebreakConverter::eLinebreakSpace));
aOut.ReplaceSubstring(NS_LITERAL_CSTRING("\""),
NS_LITERAL_CSTRING("\\\""));
}
return NS_OK;
}
示例4: SanitizeSingleLine
void nsTextAddress::SanitizeSingleLine( nsCString& val)
{
val.ReplaceSubstring( "\x0D\x0A", ", ");
val.ReplaceChar( 13, ' ');
val.ReplaceChar( 10, ' ');
}
示例5: GetField
PRBool nsTextAddress::GetField( const char *pLine, PRInt32 maxLen, PRInt32 index, nsCString& field, char delim)
{
PRBool result = PR_FALSE;
const char *pChar = pLine;
PRInt32 len = 0;
char tab = 9;
field.Truncate();
if (delim == tab)
tab = 0;
while (index && (len < maxLen)) {
while (((*pChar == ' ') || (*pChar == tab)) && (len < maxLen)) {
pChar++;
len++;
}
if (len >= maxLen)
break;
if (*pChar == '"') {
len = -1;
do {
len++;
pChar++;
if (((len + 1) < maxLen) && (*pChar == '"') && (*(pChar + 1) == '"')) {
len += 2;
pChar += 2;
}
} while ((len < maxLen) && (*pChar != '"'));
if (len < maxLen) {
pChar++;
len++;
}
}
if (len >= maxLen)
break;
while ((len < maxLen) && (*pChar != delim)) {
len++;
pChar++;
}
if (len >= maxLen)
break;
index--;
pChar++;
len++;
}
if (len >= maxLen) {
return( result);
}
result = PR_TRUE;
while ((len < maxLen) && ((*pChar == ' ') || (*pChar == tab))) {
len++;
pChar++;
}
const char *pStart = pChar;
PRInt32 fLen = 0;
PRBool quoted = PR_FALSE;
if (*pChar == '"') {
pStart++;
fLen = -1;
do {
pChar++;
len++;
fLen++;
if (((len + 1) < maxLen) && (*pChar == '"') && (*(pChar + 1) == '"')) {
quoted = PR_TRUE;
len += 2;
pChar += 2;
fLen += 2;
}
} while ((len < maxLen) && (*pChar != '"'));
}
else {
while ((len < maxLen) && (*pChar != delim)) {
pChar++;
len++;
fLen++;
}
}
if (!fLen) {
return( result);
}
field.Append( pStart, fLen);
field.Trim( kWhitespace);
if (quoted) {
field.ReplaceSubstring( "\"\"", "\"");
}
return( result);
}
示例6: SanitizeValue
void nsEudoraAddress::SanitizeValue( nsCString& val)
{
val.ReplaceSubstring( "\n", ", ");
val.ReplaceChar( 13, ',');
val.ReplaceChar( 10, ',');
}