本文整理汇总了C++中nsCString::EndReading方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::EndReading方法的具体用法?C++ nsCString::EndReading怎么用?C++ nsCString::EndReading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::EndReading方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsMsgI18NConvertRawBytesToUTF8
void nsMsgI18NConvertRawBytesToUTF8(const nsCString& inString,
const char* charset,
nsACString& outString)
{
if (MsgIsUTF8(inString))
{
outString.Assign(inString);
return;
}
nsAutoString utf16Text;
nsresult rv = ConvertToUnicode(charset, inString, utf16Text);
if (NS_SUCCEEDED(rv))
{
CopyUTF16toUTF8(utf16Text, outString);
return;
}
// EF BF BD (UTF-8 encoding of U+FFFD)
NS_NAMED_LITERAL_CSTRING(utf8ReplacementChar, "\357\277\275");
const char* cur = inString.BeginReading();
const char* end = inString.EndReading();
outString.Truncate();
while (cur < end) {
char c = *cur++;
if (c & char(0x80))
outString.Append(utf8ReplacementChar);
else
outString.Append(c);
}
}
示例2: IsLikelyFTP
/**
* Check if the host name starts with ftp\d*\. and it's not directly followed
* by the tld.
*/
bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
{
bool likelyFTP = false;
if (aHostSpec.EqualsIgnoreCase("ftp", 3)) {
nsACString::const_iterator iter;
nsACString::const_iterator end;
aHostSpec.BeginReading(iter);
aHostSpec.EndReading(end);
iter.advance(3); // move past the "ftp" part
while (iter != end)
{
if (*iter == '.') {
// now make sure the name has at least one more dot in it
++iter;
while (iter != end)
{
if (*iter == '.') {
likelyFTP = true;
break;
}
++iter;
}
break;
}
else if (!nsCRT::IsAsciiDigit(*iter)) {
break;
}
++iter;
}
}
return likelyFTP;
}
示例3: nsMsgI18NConvertRawBytesToUTF16
void nsMsgI18NConvertRawBytesToUTF16(const nsCString& inString,
const char* charset,
nsAString& outString)
{
if (MsgIsUTF8(inString))
{
CopyUTF8toUTF16(inString, outString);
return;
}
nsresult rv = ConvertToUnicode(charset, inString, outString);
if (NS_SUCCEEDED(rv))
return;
const char* cur = inString.BeginReading();
const char* end = inString.EndReading();
outString.Truncate();
while (cur < end) {
char c = *cur++;
if (c & char(0x80))
outString.Append(UCS2_REPLACEMENT_CHAR);
else
outString.Append(c);
}
}
示例4: 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);
}
}
示例5: while
static void
rdf_EscapeAmpersandsAndAngleBrackets(nsCString& s)
{
uint32_t newLength, origLength;
newLength = origLength = s.Length();
// Compute the length of the result string.
const char* start = s.BeginReading();
const char* end = s.EndReading();
const char* c = start;
while (c != end) {
switch (*c) {
case '&' :
newLength += sizeof(amp) - 2;
break;
case '<':
case '>':
newLength += sizeof(gt) - 2;
break;
default:
break;
}
++c;
}
if (newLength == origLength) {
// nothing to escape
return;
}
// escape the chars from the end back to the front.
s.SetLength(newLength);
// Buffer might have changed, get the pointers again
start = s.BeginReading(); // begin of string
c = start + origLength - 1; // last char in original string
char* w = s.EndWriting() - 1; // last char in grown buffer
while (c >= start) {
switch (*c) {
case '&' :
w -= 4;
nsCharTraits<char>::copy(w, amp, sizeof(amp) - 1);
break;
case '<':
w -= 3;
nsCharTraits<char>::copy(w, lt, sizeof(lt) - 1);
break;
case '>':
w -= 3;
nsCharTraits<char>::copy(w, gt, sizeof(gt) - 1);
break;
default:
*w = *c;
}
--w;
--c;
}
}
示例6:
bool
GMPChild::RecvSetNodeId(const nsCString& aNodeId)
{
// Store the per origin salt for the node id. Note: we do this in a
// separate message than RecvStartPlugin() so that the string is not
// sitting in a string on the IPC code's call stack.
mNodeId = std::string(aNodeId.BeginReading(), aNodeId.EndReading());
return true;
}
示例7: Substring
nsMediaFragmentURIParser::nsMediaFragmentURIParser(const nsCString& aSpec)
{
nsReadingIterator<char> start, end;
aSpec.BeginReading(start);
aSpec.EndReading(end);
if (FindCharInReadable('#', start, end)) {
mHash = Substring(++start, end);
}
}
示例8: GetCacheKey
nsresult nsDOMOfflineResourceList::GetCacheKey(nsIURI* aURI, nsCString& aKey) {
nsresult rv = aURI->GetAsciiSpec(aKey);
NS_ENSURE_SUCCESS(rv, rv);
// url fragments aren't used in cache keys
nsAutoCString::const_iterator specStart, specEnd;
aKey.BeginReading(specStart);
aKey.EndReading(specEnd);
if (FindCharInReadable('#', specStart, specEnd)) {
aKey.BeginReading(specEnd);
aKey = Substring(specEnd, specStart);
}
return NS_OK;
}
示例9:
nsresult
ClientKeyFromCacheKey(const nsCString& key, nsACString &result)
{
nsresult rv = NS_OK;
nsReadingIterator<char> start;
key.BeginReading(start);
nsReadingIterator<char> end;
key.EndReading(end);
if (FindCharInReadable(':', start, end)) {
++start; // advance past clientID ':' delimiter
result.Assign(Substring(start, end));
} else {
NS_ASSERTION(false, "FindCharInRead failed to find ':'");
rv = NS_ERROR_UNEXPECTED;
result.Truncate(0);
}
return rv;
}