BString: rename SetCharAt to SetByteAt
Makes it clear that it operates on bytes, not unicode codepoints. Thanks to mmlr for remembering me of this subtlety.
This commit is contained in:
parent
0c5219a1d6
commit
bdd02e0d9d
@ -309,7 +309,7 @@ public:
|
||||
// Fast low-level manipulation
|
||||
char* LockBuffer(int32 maxLength);
|
||||
BString& UnlockBuffer(int32 length = -1);
|
||||
BString& SetCharAt(int32 pos, char to);
|
||||
BString& SetByteAt(int32 pos, char to);
|
||||
|
||||
// Upercase <-> Lowercase
|
||||
BString& ToLower();
|
||||
|
@ -288,13 +288,13 @@ ExpressionTextView::SetValue(BString value)
|
||||
if (digit != 10)
|
||||
break;
|
||||
|
||||
value.SetCharAt(offset, '0');
|
||||
value.SetByteAt(offset, '0');
|
||||
}
|
||||
if (digit == 10) {
|
||||
// carry over, shift the result
|
||||
if (value[firstDigit + 1] == '.') {
|
||||
value.SetCharAt(firstDigit + 1, '0');
|
||||
value.SetCharAt(firstDigit, '.');
|
||||
value.SetByteAt(firstDigit + 1, '0');
|
||||
value.SetByteAt(firstDigit, '.');
|
||||
}
|
||||
value.Insert('1', 1, firstDigit);
|
||||
|
||||
@ -311,7 +311,7 @@ ExpressionTextView::SetValue(BString value)
|
||||
value << 'E' << exponent;
|
||||
} else {
|
||||
// increase the current digit value with one
|
||||
value.SetCharAt(offset, char(digit + 48));
|
||||
value.SetByteAt(offset, char(digit + 48));
|
||||
|
||||
// set offset to last digit
|
||||
offset = value.FindFirst('E');
|
||||
|
@ -2435,7 +2435,7 @@ BrowserWindow::_EncodeURIComponent(const BString& search)
|
||||
for (int32 i = 0; i < result.Length(); i++) {
|
||||
if (escCharList.FindFirst(result[i]) != B_ERROR) {
|
||||
sprintf(hexcode, "%02X", (unsigned int)result[i]);
|
||||
result.SetCharAt(i, '%');
|
||||
result.SetByteAt(i, '%');
|
||||
result.Insert(hexcode, i + 1);
|
||||
i += 2;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ HaikuMailFormatFilter::_RemoveExtraWhitespace(BString& name)
|
||||
if (i == remove + 1 || i == name.Length())
|
||||
remove++;
|
||||
else
|
||||
name.SetCharAt(i - spaces, ' ');
|
||||
name.SetByteAt(i - spaces, ' ');
|
||||
name.Remove(i - remove, remove);
|
||||
i -= remove;
|
||||
spaces = 0;
|
||||
|
@ -1904,7 +1904,7 @@ BString::UnlockBuffer(int32 length)
|
||||
|
||||
|
||||
BString&
|
||||
BString::SetCharAt(int32 pos, char to)
|
||||
BString::SetByteAt(int32 pos, char to)
|
||||
{
|
||||
if (pos < Length() && _MakeWritable() == B_OK)
|
||||
fPrivateData[pos] = to;
|
||||
|
@ -229,14 +229,14 @@ DNSTools::ConvertToDNSName(const BString& string)
|
||||
|
||||
// set a counts to the dot
|
||||
diff = dot - 1 - lastDot;
|
||||
outString.SetCharAt(lastDot, (char)diff);
|
||||
outString.SetByteAt(lastDot, (char)diff);
|
||||
lastDot = dot;
|
||||
}
|
||||
} else
|
||||
lastDot = 0;
|
||||
|
||||
diff = outString.CountChars() - 1 - lastDot;
|
||||
outString.SetCharAt(lastDot, (char)diff);
|
||||
outString.SetByteAt(lastDot, (char)diff);
|
||||
|
||||
return outString;
|
||||
}
|
||||
@ -259,7 +259,7 @@ DNSTools::ConvertFromDNSName(const BString& string)
|
||||
if (dot == 0)
|
||||
break;
|
||||
// set a "."
|
||||
outString.SetCharAt(nextDot, '.');
|
||||
outString.SetByteAt(nextDot, '.');
|
||||
nextDot+= dot + 1;
|
||||
}
|
||||
return outString;
|
||||
|
@ -27,7 +27,7 @@ StringCharAccessTest::PerformTest(void)
|
||||
|
||||
//&operator[]
|
||||
NextSubTest();
|
||||
string.SetCharAt(0, 'a');
|
||||
string.SetByteAt(0, 'a');
|
||||
CPPUNIT_ASSERT(strcmp(string.String(), "a simple string") == 0);
|
||||
|
||||
//ByteAt(int32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user