|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-15 15:57:02
|
Module: performous
Branch: master
Commit: 052efcdc120455467410bf0974ede3fe517d1aa4
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Jul 15 18:55:28 2009 +0300
Unicode conversions
- Convert lyrics from MIDI (per-syllable charset detection instead of per-song for now)
- Do not warn about non-UTF-8 if no filename is given to convertToUTF8
---
game/songparser-ini.cc | 6 +++++-
game/unicode.cc | 4 +---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 05a495b..82d50cb 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -50,7 +50,11 @@ void SongParser::iniParse() {
n.end = midi.get_seconds(it2->end);
n.notePrev = n.note = it2->note;
n.type = n.note > 100 ? Note::SLEEP : Note::NORMAL;
- n.syllable = it2->lyric;
+ {
+ std::stringstream ss(it2->lyric);
+ convertToUTF8(ss);
+ n.syllable = ss.str();
+ }
std::string& syl = n.syllable;
if (n.type != Note::SLEEP) {
if (!syl.empty()) {
diff --git a/game/unicode.cc b/game/unicode.cc
index 3a852ea..8c2c73c 100644
--- a/game/unicode.cc
+++ b/game/unicode.cc
@@ -7,9 +7,7 @@ void convertToUTF8( std::stringstream &_stream, std::string _filename ) {
try {
Glib::convert(_stream.str(), "UTF-8", "UTF-8"); // Test if input is UTF-8
} catch(...) {
- if( _filename.empty() ) _filename = std::string("stream");
-
- std::cerr << "WARNING: " << _filename << " is not UTF-8.\n Assuming CP1252 for now. Use recode CP1252..UTF-8 */*.txt to convert your files." << std::endl;
+ if (!_filename.empty()) std::cerr << "WARNING: " << _filename << " is not UTF-8.\n Assuming CP1252 for now. Use recode CP1252..UTF-8 */*.txt to convert your files." << std::endl;
try {
_stream.str(Glib::convert(_stream.str(), "UTF-8", "CP1252")); // Convert from Microsoft CP1252
} catch (...) {
|