Removed potential utf8-bom found in some lyrics
This commit is contained in:
@@ -159,6 +159,11 @@ namespace lms::metadata
|
|||||||
{
|
{
|
||||||
std::string_view trimmedLine{ core::stringUtils::stringTrimEnd(line) };
|
std::string_view trimmedLine{ core::stringUtils::stringTrimEnd(line) };
|
||||||
|
|
||||||
|
// Remove potential UTF8 BOM
|
||||||
|
constexpr std::string_view utf8BOM{ "\xEF\xBB\xBF" };
|
||||||
|
if (trimmedLine.starts_with(utf8BOM))
|
||||||
|
trimmedLine = trimmedLine.substr(utf8BOM.size());
|
||||||
|
|
||||||
// Skip comments
|
// Skip comments
|
||||||
if (!trimmedLine.empty() && trimmedLine.front() == '#')
|
if (!trimmedLine.empty() && trimmedLine.front() == '#')
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -72,6 +72,22 @@ namespace lms::metadata::tests
|
|||||||
EXPECT_EQ(lyrics.synchronizedLines.find(9s + 160ms)->second, "I, I just woke up from a dream");
|
EXPECT_EQ(lyrics.synchronizedLines.find(9s + 160ms)->second, "I, I just woke up from a dream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Lyrics, tagAtTheEndOfLyrics)
|
||||||
|
{
|
||||||
|
std::istringstream is{ R"([00:03.30]Ooh, ooh
|
||||||
|
[00:09.16]I, I just woke up from a dream
|
||||||
|
[id: dqsxdkbu])" };
|
||||||
|
|
||||||
|
const Lyrics lyrics{ parseLyrics(is) };
|
||||||
|
|
||||||
|
EXPECT_EQ(lyrics.unsynchronizedLines.size(), 0);
|
||||||
|
ASSERT_EQ(lyrics.synchronizedLines.size(), 2);
|
||||||
|
ASSERT_TRUE(lyrics.synchronizedLines.contains(3s + 300ms));
|
||||||
|
EXPECT_EQ(lyrics.synchronizedLines.find(3s + 300ms)->second, "Ooh, ooh");
|
||||||
|
ASSERT_TRUE(lyrics.synchronizedLines.contains(9s + 160ms));
|
||||||
|
EXPECT_EQ(lyrics.synchronizedLines.find(9s + 160ms)->second, "I, I just woke up from a dream");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Lyrics, skipEmptyBeginLines)
|
TEST(Lyrics, skipEmptyBeginLines)
|
||||||
{
|
{
|
||||||
std::istringstream is{ R"(
|
std::istringstream is{ R"(
|
||||||
|
|||||||
Reference in New Issue
Block a user