mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Add case conversion functionality
This commit is contained in:
@ -644,6 +644,36 @@ plString plString::Substr(int start, size_t size) const
|
||||
return str;
|
||||
}
|
||||
|
||||
plString plString::ToUpper() const
|
||||
{
|
||||
// TODO: Unicode-aware case conversion
|
||||
size_t size = GetSize();
|
||||
char *dupe = new char[size + 1];
|
||||
const char *self = c_str();
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
dupe[i] = toupper(self[i]);
|
||||
|
||||
// Don't re-check UTF-8 on this
|
||||
plString str;
|
||||
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
|
||||
return str;
|
||||
}
|
||||
|
||||
plString plString::ToLower() const
|
||||
{
|
||||
// TODO: Unicode-aware case conversion
|
||||
size_t size = GetSize();
|
||||
char *dupe = new char[size + 1];
|
||||
const char *self = c_str();
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
dupe[i] = tolower(self[i]);
|
||||
|
||||
// Don't re-check UTF-8 on this
|
||||
plString str;
|
||||
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size);
|
||||
return str;
|
||||
}
|
||||
|
||||
plString &plString::operator+=(const plString &str)
|
||||
{
|
||||
size_t catsize = GetSize() + str.GetSize();
|
||||
|
@ -260,6 +260,11 @@ public:
|
||||
plString Left(size_t size) const { return Substr(0, size); }
|
||||
plString Right(size_t size) const { return Substr(GetSize() - size, size); }
|
||||
|
||||
// NOTE: Does ::Compare(blah, kCaseInsensitive) make more sense? If
|
||||
// so, use that instead -- it's faster and more efficient!
|
||||
plString ToUpper() const;
|
||||
plString ToLower() const;
|
||||
|
||||
public:
|
||||
struct less : public std::binary_function<plString, plString, bool>
|
||||
{
|
||||
|
Reference in New Issue
Block a user