[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users-jp 01391] %charset and m17n lib



m17n libを使うと %charset が無視されてしまうようです。
このパッチでいいでしょうか?

--- mgp-1.11b.orig/m17n.c
+++ mgp-1.11b/m17n.c
@@ -151,6 +151,10 @@
 		   	return cached_mt[i];
 		}
 
+	if (!mt && mgp_charset[0] != '\0') {
+		coding = mconv_resolve_coding (msymbol (mgp_charset));
+		if (coding) mt = mconv_decode_buffer (coding, p, len);
+	}
 	if (strchr (p, '\033')) {
 		/* Try ISO-2022 encoding.  */
 		coding = mconv_resolve_coding (msymbol ("iso-2022-7bit"));
@@ -165,6 +169,12 @@
 		/* Try the encoding of the current locale.  */
 		mt = mconv_decode_buffer (Mnil, p, len);
 	}
+	if (!mt) {
+		/* XXX: wrong encoding? */
+		fprintf(stderr, "unexpected byte sequence found.\n");
+		fprintf(stderr, "  (expecting: %s (by %%charset), iso-2022-7bit, utf-8, default encoding of locale)\n", mgp_charset);
+		exit(1);
+	}
 
 	bzero(cached_txt[cached_count], BUFSIZ);
 	if (cached_mt[cached_count]) 

-- 
鵜飼文敏