mirror of
https://github.com/DanielSWolf/rhubarb-lip-sync.git
synced 2026-11-21 12:25:08 +00:00
Merged ascii.cpp into stringTools.cpp
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
using std::string;
|
||||
using std::u32string;
|
||||
using std::vector;
|
||||
using boost::optional;
|
||||
|
||||
vector<string> splitIntoLines(const string& s) {
|
||||
vector<string> lines;
|
||||
@@ -79,3 +81,19 @@ vector<string> wrapString(const string& s, int lineLength, int hangingIndent) {
|
||||
return lines;
|
||||
}
|
||||
|
||||
optional<char> toASCII(char32_t ch) {
|
||||
switch (ch) {
|
||||
#include "asciiCases.cpp"
|
||||
default:
|
||||
return ch < 0x80 ? static_cast<char>(ch) : optional<char>();
|
||||
}
|
||||
}
|
||||
|
||||
string toASCII(const u32string& s) {
|
||||
string result;
|
||||
for (char32_t ch : s) {
|
||||
optional<char> ascii = toASCII(ch);
|
||||
if (ascii) result.append(1, *ascii);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user