summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-21 06:44:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-21 06:44:54 -0700
commitf1f24ca5cfb5fde42405ee2ae3b53eb397e9133c (patch)
tree97960961f9dd1ef090e38f8395ccb3d82c4f7089 /utf8.c
parent0168c96019eb9247d0cf7453a9b6b6adad5c2905 (diff)
downloadtxr-f1f24ca5cfb5fde42405ee2ae3b53eb397e9133c.tar.gz
txr-f1f24ca5cfb5fde42405ee2ae3b53eb397e9133c.tar.bz2
txr-f1f24ca5cfb5fde42405ee2ae3b53eb397e9133c.zip
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.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c4
1 files changed, 3 insertions, 1 deletions
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)