patches/gobby-04-g11n-encoding.diff
author Jon Tibble <meths@btinternet.com>
Sat, 06 Oct 2012 16:11:50 +0100
branchs11express-2010-11
changeset 22109 db10202d5f6d
parent 18110 93461edb1490
permissions -rw-r--r--
Added tag oi_151a_prestable7 for changeset 25dee50cecca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18110
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     1
--- gobby-0.4.6/src/encoding.cpp.orig	2007-11-23 21:50:26.000000000 +0900
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     2
+++ gobby-0.4.6/src/encoding.cpp	2008-09-24 22:11:58.241855000 +0900
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     3
@@ -41,23 +41,43 @@ Glib::ustring convert_to_utf8(const std:
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     4
 
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     5
 const std::vector<std::string>& Gobby::Encoding::get_encodings()
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     6
 {
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     7
-	static const std::string encodings[] = {
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     8
-		"UTF-8",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
     9
-		"ISO-8859-1",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    10
-		"ISO-8859-15",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    11
-		"UTF-7",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    12
-		"UTF-16",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    13
-		"UCS-2",
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    14
-		"UCS-4"
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    15
-	};
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    16
-
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    17
-	static const std::size_t encoding_count =
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    18
-		sizeof(encodings) / sizeof(encodings[0]);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    19
-
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    20
-	static std::vector<std::string> encoding_vec(
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    21
-		encodings,
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    22
-		encodings + encoding_count
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    23
-	);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    24
+	static std::size_t encoding_count = 0;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    25
+	static std::vector<std::string> encoding_vec(encoding_count);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    26
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    27
+	if(encoding_count != 0)
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    28
+		return encoding_vec;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    29
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    30
+	static const char *encoding_list =
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    31
+	/* Translators: the msgid should not be localized.
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    32
+	 * The msgstr is the list of encodings separated by bar. e.g.
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    33
+	 * msgstr "EUC-JP|SHIFT-JIS|ISO-2022-JP|UTF-8|UCS-2|UCS-4" */
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    34
+		N_("UTF-8|ISO-8859-1|ISO-8859-15|UTF-7|UTF-16|UCS-2|UCS-4");
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    35
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    36
+	static gchar **encodings = g_strsplit(_(encoding_list), "|", 0);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    37
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    38
+	encoding_count = g_strv_length(encodings);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    39
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    40
+	encoding_vec.resize(encoding_count);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    41
+	for(int i = 0; i < encoding_count; i++)
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    42
+		encoding_vec[i] = encodings[i];
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    43
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    44
+	g_strfreev(encodings);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    45
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    46
+	static const char* current_encoding = NULL;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    47
+	if(!g_get_charset(&current_encoding))
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    48
+	{
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    49
+		int i;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    50
+		for(i = 0; i < encoding_count; i++)
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    51
+		{
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    52
+			if(!strcmp(encoding_vec[i].c_str(), current_encoding))
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    53
+				break;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    54
+		}
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    55
+		if(i == encoding_count)
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    56
+		{
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    57
+			encoding_vec.resize(++encoding_count);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    58
+			encoding_vec[encoding_count - 1] = g_strdup(current_encoding);
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    59
+		}
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    60
+	}
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    61
 
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    62
 	return encoding_vec;
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    63
 }
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    64
--- gobby-0.4.6/inc/common.hpp.orig	2008-09-24 03:10:59.654015000 +0900
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    65
+++ gobby-0.4.6/inc/common.hpp	2008-09-24 13:10:23.015627000 +0900
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    66
@@ -21,6 +21,8 @@
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    67
 
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    68
 #include "net6/gettext_package.hpp"
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    69
 
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    70
+#define N_(String) (String)
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    71
+
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    72
 namespace Gobby
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    73
 {
93461edb1490 2010-06-10 Christian Kelly <[email protected]>
chrisk
parents:
diff changeset
    74