Logo Search packages:      
Sourcecode: ardour version File versions  Download package

bool Glib::ustring::is_ascii (  )  const

Check whether the string is plain 7-bit ASCII.

Unlike any other ustring method, is_ascii() is safe to use on invalid UTF-8 strings. If the string isn't valid UTF-8, it cannot be valid ASCII either, therefore is_ascii() will just return false then.
Returns:
Whether the string contains only ASCII characters.

Definition at line 1121 of file ustring.cc.

{
  const char* p = string_.data();
  const char *const pend = p + string_.size();

  for(; p != pend; ++p)
  {
    if((*p & '\x80') != 0)
      return false;
  }

  return true;
}


Generated by  Doxygen 1.6.0   Back to index