#include "debug.h"
#include "support/lstrings.h"
+#include "support/textutils.h"
#include <boost/current_function.hpp>
os << "\\" << s;
// We need an extra ' ' unless this is a single-char-non-ASCII name
// or anything non-ASCII follows
- if (s.size() != 1 || isalpha(s[0]))
+ if (s.size() != 1 || isAlphaASCII(s[0]))
os.pendingSpace(true);
}
#include "undo.h"
#include "support/lstrings.h"
+#include "support/textutils.h"
#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
return true;
}
- if (isalpha(c)) {
+ if (isAlphaASCII(c)) {
cur.activeMacro()->setName(name + docstring(1, c));
return true;
}
#include "LaTeXFeatures.h"
#include "debug.h"
-#include <cctype>
+#include "support/textutils.h"
namespace lyx {
// $,#, etc. In theory the restriction based on catcodes, but then
// we do not handle catcodes very well, let alone cat code changes,
// so being outside the alpha range is good enough.
- if (name().size() == 1 && !std::isalpha(name()[0]))
+ if (name().size() == 1 && !isAlphaASCII(name()[0]))
return;
os.pendingSpace(true);
#include "MathStream.h"
#include "support/lyxalgo.h"
-
-
-namespace {
-
-bool isAlpha(char c)
-{
- return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
-}
-
-
-bool isAlpha(lyx::char_type c)
-{
- return c < 0x80 && isAlpha(static_cast<char>(c));
-}
-
-}
+#include "support/textutils.h"
namespace lyx {
WriteStream & operator<<(WriteStream & ws, docstring const & s)
{
if (ws.pendingSpace() && s.length() > 0) {
- if (isAlpha(s[0]))
+ if (isAlphaASCII(s[0]))
ws.os() << ' ';
ws.pendingSpace(false);
}
WriteStream & operator<<(WriteStream & ws, char const * s)
{
if (ws.pendingSpace() && strlen(s) > 0) {
- if (isAlpha(s[0]))
+ if (isAlphaASCII(s[0]))
ws.os() << ' ';
ws.pendingSpace(false);
}
WriteStream & operator<<(WriteStream & ws, char c)
{
if (ws.pendingSpace()) {
- if (isAlpha(c))
+ if (isAlphaASCII(c))
ws.os() << ' ';
ws.pendingSpace(false);
}
#include "support/lstrings.h"
#include "support/std_ostream.h"
#include "support/convert.h"
+#include "support/textutils.h"
#include <map>
#include <sstream>
return (*known).second;
// make sure it starts with a letter
- if (!isalpha(*it) && allowed.find(*it) >= allowed.size())
+ if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size())
content += "x";
bool mangle = false;
for (; it != end; ++it) {
char c = *it;
- if (isalpha(c) || isdigit(c) || c == '-' || c == '.'
+ if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.'
|| allowed.find(c) < allowed.size())
content += c;
else if (c == '_' || c == ' ') {
if (mangle) {
content += "-" + convert<docstring>(mangleID++);
}
- else if (isdigit(content[content.size() - 1])) {
+ else if (isDigitASCII(content[content.size() - 1])) {
content += ".";
}
}
+bool isAlphaASCII(char_type c)
+{
+ return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
+}
+
+
bool isPrintable(char_type c)
{
if (!is_utf16(c)) {
return ucs4_to_qchar(c).isDigit();
}
+
+bool isDigitASCII(char_type c)
+{
+ return '0' <= c && c <= '9';
+}
+
} // namespace lyx
/// return true if a char is alphabetical (including accented chars)
bool isLetterChar(char_type c);
+/// return whether \p c is an alphabetic character in the ASCII range
+bool isAlphaASCII(char_type c);
+
/// return true if the char is printable
bool isPrintable(char_type c);
/// return true if a unicode char is a digit.
bool isDigit(char_type c);
+/// return whether \p c is a digit in the ASCII range
+bool isDigitASCII(char_type c);
+
} // namespace lyx
#endif // TEXTUTILS_H