Move toUpper() from StringUtils to the JournalViewModel

pull/347/head^2
Andrei Kortunov 7 years ago
parent a8bf4cdd98
commit 94c0e3ed10

@ -314,7 +314,7 @@ struct JournalViewModelImpl : JournalViewModel
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i) for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
{ {
Utf8Stream stream (i->first.c_str()); Utf8Stream stream (i->first.c_str());
uint32_t first = Misc::StringUtils::toUpper(stream.peek()); uint32_t first = toUpper(stream.peek());
if (first != character) if (first != character)
continue; continue;
@ -323,6 +323,23 @@ struct JournalViewModelImpl : JournalViewModel
} }
} }
static uint32_t toUpper(uint32_t ch)
{
// Russian alphabet
if (ch >= 0x0430 && ch < 0x0450)
ch -= 0x20;
// Cyrillic IO character
if (ch == 0x0451)
ch -= 0x50;
// Latin alphabet
if (ch >= 0x61 && ch < 0x80)
ch -= 0x20;
return ch;
}
struct TopicEntryImpl : BaseEntry <MWDialogue::Topic::TEntryIter, TopicEntry> struct TopicEntryImpl : BaseEntry <MWDialogue::Topic::TEntryIter, TopicEntry>
{ {
MWDialogue::Topic const & mTopic; MWDialogue::Topic const & mTopic;

@ -1,7 +1,6 @@
#ifndef MISC_STRINGOPS_H #ifndef MISC_STRINGOPS_H
#define MISC_STRINGOPS_H #define MISC_STRINGOPS_H
#include <stdint.h>
#include <cctype> #include <cctype>
#include <cstring> #include <cstring>
#include <string> #include <string>
@ -57,23 +56,6 @@ public:
}; };
} }
static uint32_t toUpper(uint32_t ch)
{
// Russian alphabet
if (ch >= 0x0430 && ch < 0x0450)
ch -= 0x20;
// Cyrillic YO character
if (ch == 0x0451)
ch -= 0x50;
// Latin alphabet
if (ch >= 0x61 && ch < 0x80)
ch -= 0x20;
return ch;
}
static bool ciLess(const std::string &x, const std::string &y) { static bool ciLess(const std::string &x, const std::string &y) {
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), ci()); return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), ci());
} }

Loading…
Cancel
Save