Add methods to check if this string is Latin1/ASCII compatible.

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@768593 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler 2008-01-30 12:42:23 +00:00
parent 3f19588bb1
commit bdad22b3c6
2 changed files with 28 additions and 0 deletions

View File

@ -461,6 +461,24 @@ String String::stripWhiteSpace() const
return String(wstring(begin, end + 1));
}
bool String::isLatin1() const
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
if(*it >= 256)
return false;
}
return true;
}
bool String::isAscii() const
{
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
if(*it >= 128)
return false;
}
return true;
}
String String::number(int n) // static
{
if(n == 0)

View File

@ -292,6 +292,16 @@ namespace TagLib {
*/
String stripWhiteSpace() const;
/*!
* Returns true if the file only uses characters required by Latin1.
*/
bool isLatin1() const;
/*!
* Returns true if the file only uses characters required by (7-bit) ASCII.
*/
bool isAscii() const;
/*!
* Converts the base-10 integer \a n to a string.
*/