mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Handle file names with non-ASCII characters correctly.
This commit is contained in:
parent
09fbbec05a
commit
8a4068137e
@ -1,3 +1,8 @@
|
||||
2004-02-28 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvmerge: bug fix: File names with non-ASCII characters like
|
||||
Umlaute are handled correctly.
|
||||
|
||||
2004-02-27 Moritz Bunkus <moritz@bunkus.org>
|
||||
|
||||
* mkvmerge: bug fix: Some RealMedia files contain several tracks
|
||||
|
@ -1235,7 +1235,7 @@ static void identify(const char *filename) {
|
||||
|
||||
file = (filelist_t *)safemalloc(sizeof(filelist_t));
|
||||
|
||||
file->name = safestrdup(filename);
|
||||
file->name = from_utf8(cc_local_utf8, filename);
|
||||
file->type = get_type(file->name);
|
||||
ti.fname = file->name;
|
||||
|
||||
@ -1797,9 +1797,9 @@ static void parse_args(int argc, char **argv) {
|
||||
|
||||
file = (filelist_t *)safemalloc(sizeof(filelist_t));
|
||||
|
||||
file->name = safestrdup(this_arg);
|
||||
file->name = from_utf8(cc_local_utf8, this_arg);
|
||||
file->type = get_type(file->name);
|
||||
ti->fname = safestrdup(this_arg);
|
||||
ti->fname = from_utf8(cc_local_utf8, this_arg);
|
||||
|
||||
if (file->type == TYPEUNKNOWN)
|
||||
mxerror("File '%s' has unknown type. Please have a look "
|
||||
@ -2093,6 +2093,7 @@ void create_next_output_file() {
|
||||
this_outfile = create_output_name();
|
||||
else
|
||||
this_outfile = outfile;
|
||||
this_outfile = from_utf8(cc_local_utf8, this_outfile);
|
||||
|
||||
// Open the output file.
|
||||
try {
|
||||
|
@ -234,7 +234,7 @@ strip(vector<wxString> &v,
|
||||
}
|
||||
|
||||
wxString
|
||||
to_utf8_wx(wxString &src) {
|
||||
to_utf8(const wxString &src) {
|
||||
char *utf8;
|
||||
wxString retval;
|
||||
|
||||
@ -245,6 +245,49 @@ to_utf8_wx(wxString &src) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
wxString
|
||||
from_utf8(const wxString &src) {
|
||||
char *local;
|
||||
wxString retval;
|
||||
|
||||
local = from_utf8(cc_local_utf8, src.c_str());
|
||||
retval = local;
|
||||
safefree(local);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
wxString
|
||||
unescape(const wxString &src) {
|
||||
wxString dst;
|
||||
int current_char, next_char;
|
||||
|
||||
if (src.length() <= 1)
|
||||
return src;
|
||||
next_char = 1;
|
||||
current_char = 0;
|
||||
while (current_char < src.length()) {
|
||||
if (src[current_char] == wxC('\\')) {
|
||||
if (next_char == src.length()) // This is an error...
|
||||
dst += wxC('\\');
|
||||
else {
|
||||
if (src[next_char] == wxC('2'))
|
||||
dst += wxC('"');
|
||||
else if (src[next_char] == wxC('s'))
|
||||
dst += wxC(' ');
|
||||
else
|
||||
dst += src[next_char];
|
||||
current_char++;
|
||||
}
|
||||
} else
|
||||
dst += src[current_char];
|
||||
current_char++;
|
||||
next_char = current_char + 1;
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
bool
|
||||
is_popular_language(const char *lang) {
|
||||
return
|
||||
@ -1034,7 +1077,7 @@ void mmg_dialog::update_command_line() {
|
||||
cmdline += " " + shell_escape(clargs[i]);
|
||||
}
|
||||
|
||||
cmdline = to_utf8_wx(cmdline);
|
||||
cmdline = to_utf8(cmdline);
|
||||
if (old_cmdline != cmdline)
|
||||
tc_cmdline->SetValue(cmdline);
|
||||
}
|
||||
|
@ -103,6 +103,9 @@ vector<wxString> split(const wxString &src, const char *pattern = ",",
|
||||
wxString join(const char *pattern, vector<wxString> &strings);
|
||||
wxString &strip(wxString &s, bool newlines = false);
|
||||
vector<wxString> & strip(vector<wxString> &v, bool newlines = false);
|
||||
wxString to_utf8(const wxString &src);
|
||||
wxString from_utf8(const wxString &src);
|
||||
wxString unescape(const wxString &src);
|
||||
|
||||
class mmg_app: public wxApp {
|
||||
public:
|
||||
|
@ -445,9 +445,9 @@ void tab_input::enable_ar_controls(mmg_track_t *track) {
|
||||
|
||||
void tab_input::on_add_file(wxCommandEvent &evt) {
|
||||
mmg_file_t file;
|
||||
wxString name, command, id, type, exact;
|
||||
wxString file_name, name, command, id, type, exact;
|
||||
wxArrayString output, errors;
|
||||
vector<string> args, pair;
|
||||
vector<wxString> args, pair;
|
||||
int result, pos;
|
||||
unsigned int i, k;
|
||||
|
||||
@ -486,9 +486,10 @@ void tab_input::on_add_file(wxCommandEvent &evt) {
|
||||
|
||||
if(dlg.ShowModal() == wxID_OK) {
|
||||
last_open_dir = dlg.GetDirectory();
|
||||
file_name = dlg.GetPath();
|
||||
|
||||
command = "\"" + mkvmerge_path + "\" --identify-verbose \"" +
|
||||
dlg.GetPath() + "\"";
|
||||
command = "\"" + mkvmerge_path + "\" --identify-verbose \"" + file_name +
|
||||
"\"";
|
||||
result = wxExecute(command, output, errors);
|
||||
if ((result < 0) || (result > 1)) {
|
||||
name.Printf("'mkvmerge -i' failed. Return code: %d\n\n", result);
|
||||
@ -549,20 +550,16 @@ void tab_input::on_add_file(wxCommandEvent &evt) {
|
||||
track.timecodes = new wxString("");
|
||||
|
||||
if (info.length() > 0) {
|
||||
args = split(info.c_str(), " ");
|
||||
args = split(info, " ");
|
||||
for (k = 0; k < args.size(); k++) {
|
||||
pair = split(args[k].c_str(), ":", 2);
|
||||
pair = split(args[k], ":", 2);
|
||||
if (pair.size() != 2)
|
||||
continue;
|
||||
if (pair[0] == "track_name") {
|
||||
char *name_local;
|
||||
name_local =
|
||||
from_utf8(cc_local_utf8, unescape(pair[1].c_str()).c_str());
|
||||
*track.track_name = name_local;
|
||||
safefree(name_local);
|
||||
*track.track_name = from_utf8(unescape(pair[1]));
|
||||
track.track_name_was_present = true;
|
||||
} else if (pair[0] == "language")
|
||||
*track.language = unescape(pair[1].c_str()).c_str();
|
||||
*track.language = unescape(pair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -603,15 +600,11 @@ void tab_input::on_add_file(wxCommandEvent &evt) {
|
||||
file.container = TYPEUNKNOWN;
|
||||
|
||||
if (info.length() > 0) {
|
||||
args = split(info.c_str(), " ");
|
||||
args = split(info, " ");
|
||||
for (k = 0; k < args.size(); k++) {
|
||||
pair = split(args[k].c_str(), ":", 2);
|
||||
pair = split(args[k], ":", 2);
|
||||
if ((pair.size() == 2) && (pair[0] == "title")) {
|
||||
char *title_local;
|
||||
title_local =
|
||||
from_utf8(cc_local_utf8, unescape(pair[1].c_str()).c_str());
|
||||
*file.title = title_local;
|
||||
safefree(title_local);
|
||||
*file.title = from_utf8(unescape(pair[1]));
|
||||
title_was_present = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user