From 3d48f1854235dfb51475757a3545dd4846b46c4f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 4 Feb 2013 19:17:04 -0800 Subject: [PATCH] Display the full list of supported character sets if detection fails catastrophically --- aegisub/src/charset_detect.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aegisub/src/charset_detect.cpp b/aegisub/src/charset_detect.cpp index a61c65345..daf0e923b 100644 --- a/aegisub/src/charset_detect.cpp +++ b/aegisub/src/charset_detect.cpp @@ -39,6 +39,7 @@ #include "compat.h" #include +#include #include #include @@ -55,7 +56,7 @@ std::string GetEncoding(agi::fs::path const& filename) { try { list = agi::charset::DetectAll(filename); } catch (const agi::charset::UnknownCharset&) { - /// @todo If the charset is unknown we need to display a complete list of character sets. + // will be set to the full list of charsets below } if (list.size() == 1) { @@ -74,11 +75,16 @@ std::string GetEncoding(agi::fs::path const& filename) { LOG_I("charset/file") << filename << " (" << log_choice << ")"; + if (choices.empty()) + choices = agi::charset::GetEncodingsList(); + int choice = wxGetSingleChoiceIndex( _("Aegisub could not narrow down the character set to a single one.\nPlease pick one below:"), _("Choose character set"), choices); if (choice == -1) throw agi::UserCancelException("Cancelled encoding selection"); + if (list.empty()) + return agi::charset::GetEncodingsList>()[choice]; return list[choice].second; }