mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
forgot this
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17355 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0418d14704
commit
56eea075fd
75
src/support/textutils.C
Normal file
75
src/support/textutils.C
Normal file
@ -0,0 +1,75 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file textutils.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Georg Baum
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
// FIXME: I can think of a better name for this file ...
|
||||
|
||||
#include "support/textutils.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
namespace {
|
||||
/// Maximum valid UCS4 code point
|
||||
char_type const ucs4_max = 0x10ffff;
|
||||
}
|
||||
|
||||
|
||||
bool isLetterChar(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are letters
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isLetter();
|
||||
}
|
||||
|
||||
|
||||
bool isPrintable(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable
|
||||
return true;
|
||||
}
|
||||
return ucs4_to_qchar(c).isPrint();
|
||||
}
|
||||
|
||||
|
||||
bool isPrintableNonspace(char_type c)
|
||||
{
|
||||
if (!is_utf16(c)) {
|
||||
if (c > ucs4_max)
|
||||
// outside the UCS4 range
|
||||
return false;
|
||||
// assume that all non-utf16 characters are printable and
|
||||
// no space
|
||||
return true;
|
||||
}
|
||||
QChar const qc = ucs4_to_qchar(c);
|
||||
return qc.isPrint() && !qc.isSpace();
|
||||
}
|
||||
|
||||
|
||||
bool isDigit(char_type c)
|
||||
{
|
||||
if (!is_utf16(c))
|
||||
// assume that no non-utf16 character is a digit
|
||||
// c outside the UCS4 range is catched as well
|
||||
return false;
|
||||
return ucs4_to_qchar(c).isDigit();
|
||||
}
|
||||
|
||||
} // namespace lyx
|
Loading…
Reference in New Issue
Block a user