diff --git a/src/rime/algo/encoder.cc b/src/rime/algo/encoder.cc index 8f117a96d5..e519e0bcc6 100644 --- a/src/rime/algo/encoder.cc +++ b/src/rime/algo/encoder.cc @@ -20,7 +20,7 @@ string RawCode::ToString() const { } void RawCode::FromString(const string& code_str) { - *dynamic_cast*>(this) = strings::split(code_str, " "); + *dynamic_cast*>(this) = strings::split(code_str, " ", strings::SplitBehavior::SkipToken); } TableEncoder::TableEncoder(PhraseCollector* collector) diff --git a/src/rime/algo/strings.cc b/src/rime/algo/strings.cc index a0ab82626a..acbb040ae9 100644 --- a/src/rime/algo/strings.cc +++ b/src/rime/algo/strings.cc @@ -8,7 +8,7 @@ vector split(const string& str, SplitBehavior behavior) { vector strings; size_t lastPos, pos; - if (behavior == SplitBehavior::SkipEmpty) { + if (behavior == SplitBehavior::SkipToken) { lastPos = str.find_first_not_of(delim, 0); } else { lastPos = 0; @@ -17,7 +17,7 @@ vector split(const string& str, while (std::string::npos != pos || std::string::npos != lastPos) { strings.emplace_back(str.substr(lastPos, pos - lastPos)); - if (behavior == SplitBehavior::SkipEmpty) { + if (behavior == SplitBehavior::SkipToken) { lastPos = str.find_first_not_of(delim, pos); } else { if (pos == std::string::npos) { @@ -31,7 +31,7 @@ vector split(const string& str, }; vector split(const string& str, const string& delim) { - return split(str, delim, SplitBehavior::SkipEmpty); + return split(str, delim, SplitBehavior::KeepToken); }; } // namespace strings diff --git a/src/rime/algo/strings.h b/src/rime/algo/strings.h index 2bd570f1c6..222476d2fa 100644 --- a/src/rime/algo/strings.h +++ b/src/rime/algo/strings.h @@ -7,7 +7,7 @@ namespace rime { namespace strings { -enum class SplitBehavior { KeepEmpty, SkipEmpty }; +enum class SplitBehavior { KeepToken, SkipToken }; vector split(const string& str, const string& delim,