25 lines
769 B
C++
25 lines
769 B
C++
#include "concordia/common/text_utils.hpp"
|
|
#include <boost/algorithm/string.hpp>
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
#include <boost/locale.hpp>
|
|
#include "utf8/utf8.h"
|
|
|
|
|
|
TextUtils::TextUtils() {
|
|
_lowerConverter =
|
|
StringCaseConverterManager::getInstance().getLowerCaseConverter("pl");
|
|
_upperConverter =
|
|
StringCaseConverterManager::getInstance().getUpperCaseConverter("pl");
|
|
}
|
|
|
|
std::string TextUtils::toLowerCase(const std::string & text) {
|
|
if (!utf8::is_valid(text.begin(), text.end())) {
|
|
throw ConcordiaException("Bad input encoding, use UTF-8");
|
|
}
|
|
return simpleConvert(*_lowerConverter, text);
|
|
}
|
|
|
|
std::string TextUtils::toUpperCase(const std::string & text) {
|
|
return simpleConvert(*_upperConverter, text);
|
|
}
|