18861N/A@@ -41,23 +41,43 @@ Glib::ustring convert_to_utf8(const std:
18861N/A const std::vector<std::string>& Gobby::Encoding::get_encodings()
18861N/A- static const std::string encodings[] = {
18861N/A- static const std::size_t encoding_count =
18861N/A- sizeof(encodings) / sizeof(encodings[0]);
18861N/A- static std::vector<std::string> encoding_vec(
18861N/A+ static std::size_t encoding_count = 0;
18861N/A+ static std::vector<std::string> encoding_vec(encoding_count);
18861N/A+ static const char *encoding_list =
18861N/A+ /* Translators: the msgid should not be localized.
18861N/A+ * The msgstr is the list of encodings separated by bar.
e.g. 18861N/A+ * msgstr "EUC-JP|SHIFT-JIS|ISO-2022-JP|UTF-8|UCS-2|UCS-4" */
18861N/A+ N_("UTF-8|ISO-8859-1|ISO-8859-15|UTF-7|UTF-16|UCS-2|UCS-4");
18861N/A+ static gchar **encodings = g_strsplit(_(encoding_list), "|", 0);
18861N/A+ encoding_count = g_strv_length(encodings);
18861N/A+ for(int i = 0; i < encoding_count; i++)
18861N/A+ encoding_vec[i] = encodings[i];
18861N/A+ static const char* current_encoding = NULL;
18861N/A+ if(!g_get_charset(¤t_encoding))
18861N/A+ for(i = 0; i < encoding_count; i++)
18861N/A+ if(!strcmp(encoding_vec[i].c_str(), current_encoding))
18861N/A+ encoding_vec[encoding_count - 1] = g_strdup(current_encoding);