summaryrefslogtreecommitdiff
path: root/utf8.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-10-10 21:18:37 -0600
committerKarl Williamson <khw@cpan.org>2016-10-13 11:18:12 -0600
commitf9380377ac81dfbd87f997094a742406eb899a15 (patch)
tree399236fb4d72c139a7c90e44fc309795ee41ad93 /utf8.h
parent3757e55dd9611aede000f6f036237c4fda19b4f6 (diff)
downloadperl-f9380377ac81dfbd87f997094a742406eb899a15.tar.gz
Add utf8n_to_uvchr_error
This new function behaves like utf8n_to_uvchr(), but takes an extra parameter that points to a U32 which will be set to 0 if no errors are found; otherwise each error found will set a bit in it. This can be used by the caller to figure out precisely what the error(s) is/are. Previously, one would have to capture and parse the warning/error messages raised. This can be used, for example, to customize the messages to the expected end-user's knowledge level.
Diffstat (limited to 'utf8.h')
-rw-r--r--utf8.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/utf8.h b/utf8.h
index c55ce26f8e..aa1c69da4e 100644
--- a/utf8.h
+++ b/utf8.h
@@ -72,6 +72,8 @@ the string is invariant.
#define utf8_to_uvchr_buf(s, e, lenp) \
utf8n_to_uvchr(s, (U8*)(e) - (U8*)(s), lenp, \
ckWARN_d(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY)
+#define utf8n_to_uvchr(s, len, lenp, flags) \
+ utf8n_to_uvchr_error(s, len, lenp, flags, 0)
#define to_uni_fold(c, p, lenp) _to_uni_fold_flags(c, p, lenp, FOLD_FLAGS_FULL)
#define to_utf8_fold(c, p, lenp) _to_utf8_fold_flags(c, p, lenp, FOLD_FLAGS_FULL)