+std::string
+ExportHandler::toc_escape_filename (const std::string& txt)
+{
+ std::string out;
+
+ out = '"';
+
+ // We iterate byte-wise not character-wise over a UTF-8 string here,
+ // because we only want to translate backslashes and double quotes
+ for (std::string::const_iterator c = txt.begin(); c != txt.end(); ++c) {
+
+ if (*c == '"') {
+ out += "\\\"";
+ } else if (*c == '\\') {
+ out += "\\134";
+ } else {
+ out += *c;
+ }
+ }
+
+ out += '"';
+
+ return out;
+}
+
+std::string
+ExportHandler::cue_escape_cdtext (const std::string& txt)
+{
+ std::string latin1_txt;
+ std::string out;
+
+ try {
+ latin1_txt = Glib::convert (txt, "ISO-8859-1", "UTF-8");
+ } catch (Glib::ConvertError& err) {
+ throw Glib::ConvertError (err.code(), string_compose (_("Cannot convert %1 to Latin-1 text"), txt));
+ }
+
+ // does not do much mor than UTF-8 to Latin1 translation yet, but
+ // that may have to change if cue parsers in burning programs change
+ out = '"' + latin1_txt + '"';
+
+ return out;
+}
+