Core: String::GetCharCount

git-svn-id: svn://ultimatepp.org/upp/trunk@3835 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-09-07 07:54:45 +00:00
parent d6bd9c9bd0
commit 4f654ccc2b
3 changed files with 13 additions and 0 deletions

View file

@ -307,6 +307,11 @@ WString String::ToWString() const
return WString(Begin(), GetCount());
}
int String::GetCharCount() const
{
return GetDefaultCharset() == CHARSET_UTF8 ? utf8len(Begin(), GetCount()) : GetCount();
}
String::String(StringBuffer& b)
{
if(b.begin == b.buffer) {

View file

@ -313,6 +313,7 @@ public:
String& operator<<=(const String& s) { if(this != &s) { String0::Free(); String0::Set(s, s.GetCount()); } return *this; }
void Shrink() { *this = String(Begin(), GetLength()); }
int GetCharCount() const;
String() {}
String(const Nuller&) {}

View file

@ -100,6 +100,13 @@ empty [* String]).&]
[s2; Reduces memory used by string to minimum (size optimization).&]
[s3; &]
[s4;%- &]
[s5;:String`:`:GetCharCount`(`)const:%- [@(0.0.255) int]_[* GetCharCount]()_[@(0.0.255) con
st]&]
[s2; Returns a number of characters contained in String. This is
equal GetCount() if default charset is not UTF`-8, but different
for UTF`-8. It is faster equivalent of ToWString().GetCount().&]
[s3;%- &]
[s4;%- &]
[s5;:String`:`:ToWString`(`)const:%- [_^WString^ WString]_[* ToWString]()_[@(0.0.255) const
]&]
[s2; Convert String to WString using current default character set.&]