From f1f24ca5cfb5fde42405ee2ae3b53eb397e9133c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 21 Apr 2016 06:44:54 -0700 Subject: Diagnose out-of-range char to UTF-8 conversion. * utf8.c (utf8_encode): Don't return zero in the out-of-range case, but throw. --- utf8.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index 7c719cf5..5d99fb1c 100644 --- a/utf8.c +++ b/utf8.c @@ -252,7 +252,9 @@ int utf8_encode(wchar_t wch, int (*put)(int ch, mem_t *ctx), mem_t *ctx) put(0x80 | (wch & 0x3F), ctx); } - return 0; + uw_throwf(error_s, + lit("cannot convert character value #x~x to UTF-8"), + num(wch), nao); } void utf8_decoder_init(utf8_decoder_t *ud) -- cgit v1.2.3