diff --git a/doc/mkvmerge.1 b/doc/mkvmerge.1
index 6559eb037..eacfa2e71 100644
--- a/doc/mkvmerge.1
+++ b/doc/mkvmerge.1
@@ -37,6 +37,12 @@ Sets the general title for the output file, e.g. the movie name.
\fB\-\-global\-tags\fR <\fIfile\fR>
Read global tags from the XML \fIfile\fR. See the section about tags
below for details.
+.TP
+\fB\-\-command\-line\-charset\fR <\fBcharset\fR>
+Sets the charset to convert strings given on the command line from. It defaults
+to the charset given by system's current locale. This settings applies to
+arguments of the following options: \fB\-\-title\fR, \fB\-\-track\-name\fR and
+\fB\-\-attachment\-description\fR.
.LP
Chapter handling: (global options)
diff --git a/src/mkvmerge.cpp b/src/mkvmerge.cpp
index c4783c6f2..d15ce23db 100644
--- a/src/mkvmerge.cpp
+++ b/src/mkvmerge.cpp
@@ -249,6 +249,7 @@ static void usage() {
" -o, --output out Write to the file 'out'.\n"
" --title
Title for this output file.\n"
" --global-tags Read global tags from a XML file.\n"
+ " --command-line-charset Charset for strings on the command line\n"
"\n Chapter handling:\n"
" --chapters Read chapter information from the file.\n"
" --chapter-language Set the 'language' element in chapter entries."
@@ -922,7 +923,7 @@ static void render_attachments(IOCallback *out) {
if (attch->description != NULL)
*static_cast
(&GetChild(*kax_a)) =
- cstr_to_UTFstring(attch->description);
+ cstrutf8_to_UTFstring(attch->description);
if (attch->mime_type != NULL)
*static_cast(&GetChild(*kax_a)) =
@@ -1082,7 +1083,7 @@ static void identify(const char *filename) {
static void parse_args(int argc, char **argv) {
track_info_t ti;
- int i, j;
+ int i, j, cc_command_line;
filelist_t *file;
char *s, *this_arg, *next_arg;
audio_sync_t async;
@@ -1111,6 +1112,8 @@ static void parse_args(int argc, char **argv) {
memset(attachment, 0, sizeof(attachment_t));
memset(&tags, 0, sizeof(tags_t));
+ cc_command_line = cc_local_utf8;
+
// Check if only information about the file is wanted. In this mode only
// two parameters are allowed: the --identify switch and the file.
if (((argc == 2) || (argc == 3)) &&
@@ -1166,6 +1169,13 @@ static void parse_args(int argc, char **argv) {
} else if (!strcmp(this_arg, "-i") || !strcmp(this_arg, "--identify"))
mxerror("'%s' can only be used with a file name. "
"No other options are allowed.\n", this_arg);
+
+ else if (!strcmp(this_arg, "--command-line-charset")) {
+ if (next_arg == NULL)
+ mxerror("'--command-line-charset' lacks the charset.\n");
+ cc_command_line = utf8_init(next_arg);
+
+ }
}
if (outfile == NULL) {
@@ -1182,7 +1192,8 @@ static void parse_args(int argc, char **argv) {
next_arg = argv[i + 1];
// Ignore the options we took care of in the first step.
- if (!strcmp(this_arg, "-o") || !strcmp(this_arg, "--output")) {
+ if (!strcmp(this_arg, "-o") || !strcmp(this_arg, "--output") ||
+ !strcmp(this_arg, "--command-line-charset")) {
i++;
continue;
}
@@ -1220,7 +1231,7 @@ static void parse_args(int argc, char **argv) {
if ((next_arg == NULL) || (next_arg[0] == 0))
mxerror("'--title' lacks the title.\n");
- tmp = to_utf8(cc_local_utf8, next_arg);
+ tmp = to_utf8(cc_command_line, next_arg);
segment_title = tmp;
safefree(tmp);
i++;
@@ -1325,11 +1336,9 @@ static void parse_args(int argc, char **argv) {
mxerror("'--attachment-description' lacks the description.\n");
if (attachment->description != NULL)
- mxwarn("More than one description given for a single attachment. "
- "Discarding '%s' and using '%s'.\n", attachment->description,
- next_arg);
+ mxwarn("More than one description given for a single attachment.\n");
safefree(attachment->description);
- attachment->description = safestrdup(next_arg);
+ attachment->description = to_utf8(cc_command_line, next_arg);
i++;
} else if (!strcmp(this_arg, "--attachment-mime-type")) {
@@ -1580,7 +1589,7 @@ static void parse_args(int argc, char **argv) {
mxerror("'--track-name' lacks its argument.\n");
parse_language(next_arg, lang, "track-name", "track name", false);
- lang.language = to_utf8(cc_local_utf8, lang.language);
+ lang.language = to_utf8(cc_command_line, lang.language);
ti.track_names->push_back(lang);
i++;
diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp
index 4fc17c99a..f2b1eb746 100644
--- a/src/mmg/mmg.cpp
+++ b/src/mmg/mmg.cpp
@@ -844,6 +844,13 @@ void mmg_dialog::update_command_line() {
clargs.Add(global_page->tc_chapters->GetValue());
}
+ if (global_page->cob_cl_charset->GetValue().Length() > 0) {
+ cmdline += "--command-line-charset \"" +
+ shell_escape(global_page->cob_cl_charset->GetValue()) + "\" ";
+ clargs.Add("--command-line-charset");
+ clargs.Add(global_page->cob_cl_charset->GetValue());
+ }
+
if (global_page->tc_global_tags->GetValue().Length() > 0) {
cmdline += "--global-tags \"" +
shell_escape(global_page->tc_global_tags->GetValue()) + "\" ";
diff --git a/src/mmg/mmg.h b/src/mmg/mmg.h
index 78903317a..3240726ea 100644
--- a/src/mmg/mmg.h
+++ b/src/mmg/mmg.h
@@ -123,6 +123,7 @@ using namespace libmatroska;
#define ID_CB_ENABLEDURATIONS 10076
#define ID_CB_ENABLETIMESLICES 10077
#define ID_CB_COMPRESSION 10078
+#define ID_CB_CLCHARSET 10079
#define ID_M_FILE_NEW 20000
#define ID_M_FILE_LOAD 20001
@@ -312,6 +313,7 @@ public:
wxComboBox *cob_chap_language, *cob_chap_charset;
wxCheckBox *cb_no_cues, *cb_no_clusters, *cb_disable_lacing;
wxCheckBox *cb_enable_durations, *cb_enable_timeslices;
+ wxComboBox *cob_cl_charset;
public:
tab_global(wxWindow *parent);
diff --git a/src/mmg/tab_global.cpp b/src/mmg/tab_global.cpp
index 4a1534270..314eea201 100644
--- a/src/mmg/tab_global.cpp
+++ b/src/mmg/tab_global.cpp
@@ -207,30 +207,49 @@ tab_global::tab_global(wxWindow *parent):
"use the tags associated with a track "
"on the 'input' tab."));
+ new wxStaticBox(this, -1, _("Other options"),
+ wxPoint(10, 355), wxSize(475, 45));
+ new wxStaticText(this, -1, _("Command line charset:"),
+ wxPoint(15, 372));
+ cob_cl_charset =
+ new wxComboBox(this, ID_CB_CLCHARSET, "", wxPoint(130, 368),
+ wxSize(130, -1), 0, NULL, wxCB_DROPDOWN |
+ wxCB_READONLY);
+ cob_cl_charset->Append("");
+ for (i = 0; i < sorted_charsets.Count(); i++)
+ cob_cl_charset->Append(sorted_charsets[i]);
+ cob_cl_charset->SetToolTip(_T("Sets the charset that is used to convert "
+ "some of the strings entered here into UTF-8. "
+ "The default is the charset given by the "
+ "system's current locale. The options that "
+ "this setting affects are: segment title, "
+ "track name and attachment description."));
+
+
new wxStaticBox(this, -1, _("Advanced options (DO NOT CHANGE!)"),
- wxPoint(10, 390), wxSize(475, 70));
+ wxPoint(10, 400), wxSize(475, 70));
cb_no_cues =
- new wxCheckBox(this, ID_CB_NOCUES, _("No cues"), wxPoint(15, 405),
+ new wxCheckBox(this, ID_CB_NOCUES, _("No cues"), wxPoint(15, 415),
wxDefaultSize, 0);
cb_no_cues->SetToolTip(_T("Do not write the cues (the index). DO NOT "
"ENABLE this option unless you REALLY know "
"what you're doing!"));
cb_no_clusters =
new wxCheckBox(this, ID_CB_NOCLUSTERSINMETASEEK,
- _("No clusters in meta seek"), wxPoint(145, 405),
+ _("No clusters in meta seek"), wxPoint(145, 415),
wxDefaultSize, 0);
cb_no_clusters->SetToolTip(_T("Do not put all the clusters into the cues "
"(the index). DO NOT ENABLE this option "
"unless you REALLY know what you're doing!"));
cb_disable_lacing =
new wxCheckBox(this, ID_CB_DISABLELACING, _("Disable lacing"),
- wxPoint(325, 405), wxDefaultSize, 0);
+ wxPoint(325, 415), wxDefaultSize, 0);
cb_disable_lacing->SetToolTip(_T("Disable lacing for audio tracks. DO NOT "
"ENSABLE this option unless you REALLY "
"know what you're doing!"));
cb_enable_durations =
new wxCheckBox(this, ID_CB_ENABLEDURATIONS, _("Enable durations"),
- wxPoint(15, 430), wxDefaultSize, 0);
+ wxPoint(15, 440), wxDefaultSize, 0);
cb_enable_durations->SetToolTip(_T("Enable durations for all blocks and not "
"only for blocks that definitely need "
"them (subtitles). DO NOT "
@@ -238,7 +257,7 @@ tab_global::tab_global(wxWindow *parent):
"know what you're doing!"));
cb_enable_timeslices =
new wxCheckBox(this, ID_CB_ENABLETIMESLICES, _("Enable timeslices"),
- wxPoint(145, 430), wxDefaultSize, 0);
+ wxPoint(145, 440), wxDefaultSize, 0);
cb_enable_durations->SetToolTip(_T("Enable timeslices for laced blocks. "
"DO NOT "
"ENSABLE this option unless you REALLY "
@@ -334,6 +353,9 @@ void tab_global::load(wxConfigBase *cfg) {
cfg->Read("global_tags", &s);
tc_global_tags->SetValue(s);
+ cfg->Read("command_line_charset", &s);
+ cob_cl_charset->SetValue(s);
+
b = false;
cfg->Read("no_cues", &b);
cb_no_cues->SetValue(b);
@@ -371,6 +393,8 @@ void tab_global::save(wxConfigBase *cfg) {
cfg->Write("global_tags", tc_global_tags->GetValue());
+ cfg->Write("command_line_charset", cob_cl_charset->GetValue());
+
cfg->Write("no_cues", cb_no_cues->IsChecked());
cfg->Write("no_clusters", cb_no_clusters->IsChecked());
cfg->Write("disable_lacing", cb_disable_lacing->IsChecked());