mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 09:06:33 +01:00
improved fix for TOC string escaping, handle anything that can be converted from UTF-8 to Latin-1
git-svn-id: svn://localhost/ardour2/branches/3.0@11323 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
6918bba170
commit
d0ef18e94e
1 changed files with 6 additions and 3 deletions
|
|
@ -599,15 +599,18 @@ ExportHandler::cd_marker_file_escape_string (const std::string& txt)
|
||||||
{
|
{
|
||||||
Glib::ustring check (txt);
|
Glib::ustring check (txt);
|
||||||
std::string out;
|
std::string out;
|
||||||
|
std::string latin1_txt;
|
||||||
char buf[5];
|
char buf[5];
|
||||||
|
|
||||||
if (!check.is_ascii()) {
|
try {
|
||||||
|
latin1_txt = Glib::convert (txt, "ISO-8859-1", "UTF-8");
|
||||||
|
} catch (...) {
|
||||||
throw Glib::ConvertError (Glib::ConvertError::NO_CONVERSION, string_compose (_("Cannot convert %1 to Latin-1 text"), txt));
|
throw Glib::ConvertError (Glib::ConvertError::NO_CONVERSION, string_compose (_("Cannot convert %1 to Latin-1 text"), txt));
|
||||||
}
|
}
|
||||||
|
|
||||||
out = '"';
|
out = '"';
|
||||||
|
|
||||||
for (std::string::const_iterator c = txt.begin(); c != txt.end(); ++c) {
|
for (std::string::const_iterator c = latin1_txt.begin(); c != latin1_txt.end(); ++c) {
|
||||||
|
|
||||||
if ((*c) == '"') {
|
if ((*c) == '"') {
|
||||||
out += "\\\"";
|
out += "\\\"";
|
||||||
|
|
@ -616,7 +619,7 @@ ExportHandler::cd_marker_file_escape_string (const std::string& txt)
|
||||||
} else if (isprint (*c)) {
|
} else if (isprint (*c)) {
|
||||||
out += *c;
|
out += *c;
|
||||||
} else {
|
} else {
|
||||||
snprintf (buf, sizeof (buf), "\\%03o", *c);
|
snprintf (buf, sizeof (buf), "\\%03o", (int) (unsigned char) *c);
|
||||||
out += buf;
|
out += buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue