about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/builtin.c21
2 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a3a870af4..447f6cfa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-09-10  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 22685: Src/builtin.c: printf "%d" \'X should handle multibyte
+	characters X.
+
 	* 22684: Src/builtin.c, Src/math.c, Src/params.c, Src/subst.c,
 	Src/utils.c, Src/zsh.h, Src/Zle/zle_hist.c, Src/Zle/zle_hist.c,
 	Src/Zle/zle_misc.c: rewrite getkeystring() to have something
diff --git a/Src/builtin.c b/Src/builtin.c
index 979075392..dbe50d13c 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3938,7 +3938,8 @@ bin_print(char *name, char **args, Options ops, int func)
 		    char *b;
 		    int l;
 		    if (*c == 'b') {
-			b = getkeystring(metafy(curarg, curlen, META_USEHEAP), &l,
+			b = getkeystring(metafy(curarg, curlen, META_USEHEAP),
+					 &l,
 					 OPT_ISSET(ops,'b') ? GETKEYS_BINDKEY :
 					 GETKEYS_PRINTF, &nnl);
 		    } else {
@@ -4004,11 +4005,25 @@ bin_print(char *name, char **args, Options ops, int func)
 
 	    if (type > 0) {
 		if (curarg && (*curarg == '\'' || *curarg == '"' )) {
+		    convchar_t cc;
+#ifdef MULTIBYTE_SUPPORT
+		    if (isset(MULTIBYTE)) {
+			mb_metacharinit();
+			(void)mb_metacharlenconv(metafy(curarg+1, curlen-1,
+							META_USEHEAP), &cc);
+		    }
+		    else
+			cc = WEOF;
+		    if (cc == WEOF)
+			cc = (curlen > 1) ? STOUC(curarg[1]) : 0;
+#else
+		    cc = (curlen > 1) ? STOUC(curarg[1]) : 0;
+#endif
 		    if (type == 2) {
-			doubleval = STOUC(curarg[1]);
+			doubleval = cc;
 			print_val(doubleval);
 		    } else {
-			intval = STOUC(curarg[1]);
+			intval = cc;
 			print_val(intval);
 		    }
 		} else {