QString const guiString(QString in)
{
- // recode specially encoded chars in file names
- return in.replace('_', ' ').replace("%26", "&").replace("%28", "(").replace("%29", ")");
+ // recode specially encoded chars in file names (URL encoding and underbar)
+ return QString(QByteArray::fromPercentEncoding(in.toUtf8())).replace('_', ' ');
}
} // namespace anon
DisplayPath(int tab, FileName const & filename)
: tab_(tab)
{
+ // Recode URL encoded chars via fromPercentEncoding()
filename_ = (filename.extension() == "lyx") ?
- toqstr(filename.onlyFileNameWithoutExt())
- : toqstr(filename.onlyFileName());
+ QString(QByteArray::fromPercentEncoding(
+ toqstr(filename.onlyFileNameWithoutExt()).toUtf8()))
+ : QString(QByteArray::fromPercentEncoding(
+ toqstr(filename.onlyFileName()).toUtf8()));
postfix_ = toqstr(filename.absoluteFilePath()).
split("/", QString::SkipEmptyParts);
postfix_.pop_back();
{
string str = path;
+ // Recode URL encoded chars.
+ str = from_percent_encoding(str);
+
// If file is from LyXDir, display it as if it were relative.
string const system = package().system_support().absFileName();
if (prefixIs(str, system) && str != system)
}
+string from_percent_encoding(string const & in)
+{
+ QByteArray input = toqstr(in).toUtf8();
+ return fromqstr(QString(QByteArray::fromPercentEncoding(input)));
+}
+
+
docstring bformat(docstring const & fmt, int arg1)
{
LATTEST(contains(fmt, from_ascii("%1$d")));
/// \p ex defines a string of characters that are excluded from the transformation
docstring to_percent_encoding(docstring const & in, docstring const & ex = docstring());
+/// Returns a string decoded from an URI/URL-style percent-encoded string \p in.
+std::string from_percent_encoding(std::string const & in);
docstring bformat(docstring const & fmt, int arg1);
docstring bformat(docstring const & fmt, long arg1);