Skip to content

Commit

Permalink
Add uv_to_utf8 family of functions
Browse files Browse the repository at this point in the history
These are the inverse of the utf8_to_uv family in GH Perl#22541.  They are
just synonyms to existing functions, and are being added to reduce
cognitive load, so if you know one name, you automatically can figure
out the inverse.
  • Loading branch information
khwilliamson committed Nov 26, 2024
1 parent 44641fd commit 089fca5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
11 changes: 11 additions & 0 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -3760,6 +3760,17 @@ Cp |U8 * |uvoffuni_to_utf8_flags_msgs \
|UV input_uv \
|const UV flags \
|NULLOK HV **msgs

Admp |U8 * |uv_to_utf8 |NN U8 *d \
|UV uv
Admp |U8 * |uv_to_utf8_flags \
|NN U8 *d \
|UV uv \
|UV flags
Admp |U8 * |uv_to_utf8_msgs|NN U8 *d \
|UV uv \
|UV flags \
|NULLOK HV **msgs
CDbp |U8 * |uvuni_to_utf8 |NN U8 *d \
|UV uv
EXdpx |bool |validate_proto |NN SV *name \
Expand Down
3 changes: 3 additions & 0 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@
# define utf8_to_bytes(a,b) Perl_utf8_to_bytes(aTHX_ a,b)
# define utf8_to_uvchr_buf_helper(a,b,c) Perl_utf8_to_uvchr_buf_helper(aTHX_ a,b,c)
# define utf8n_to_uvchr_msgs Perl_utf8n_to_uvchr_msgs
# define uv_to_utf8(a,b) Perl_uv_to_utf8(aTHX,a,b)
# define uv_to_utf8_flags(a,b,c) Perl_uv_to_utf8_flags(aTHX,a,b,c)
# define uv_to_utf8_msgs(a,b,c,d) Perl_uv_to_utf8_msgs(aTHX,a,b,c,d)
# define uvchr_to_utf8(a,b) Perl_uvchr_to_utf8(aTHX,a,b)
# define uvchr_to_utf8_flags(a,b,c) Perl_uvchr_to_utf8_flags(aTHX,a,b,c)
# define uvchr_to_utf8_flags_msgs(a,b,c,d) Perl_uvchr_to_utf8_flags_msgs(aTHX,a,b,c,d)
Expand Down
9 changes: 9 additions & 0 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,17 @@ typedef enum {
#define uvoffuni_to_utf8_flags(d,uv,flags) \
uvoffuni_to_utf8_flags_msgs(d, uv, flags, 0)

#define Perl_uvchr_to_utf8(mTHX, d, u) \
Perl_uvchr_to_utf8_flags(aTHX, d, u, 0)
#define Perl_uvchr_to_utf8_flags(mTHX, d, u, f) \
Perl_uvchr_to_utf8_flags_msgs(aTHX, d, u, f, 0)
#define Perl_uvchr_to_utf8_flags_msgs(mTHX, d, u, f , m) \
#define Perl_uv_to_utf8(mTHX, d, u) \
Perl_uv_to_utf8_flags(aTHX, d, u, 0)
#define Perl_uv_to_utf8_flags(mTHX, d, u, f) \
Perl_uv_to_utf8_msgs(aTHX, d, u, f, 0)
#define Perl_uv_to_utf8_msgs(mTHX, d, u, f , m) \
Perl_uvoffuni_to_utf8_flags_msgs(aTHX_ d, NATIVE_TO_UNI(u), f, m)

#define Perl_uvchr_to_utf8 Perl_uv_to_utf8
#define Perl_uvchr_to_utf8_flags Perl_uv_to_utf8_flags
#define Perl_uvchr_to_utf8_flags_msgs Perl_uv_to_utf8_msgs

#define utf8_to_uvchr_buf(s, e, lenp) \
utf8_to_uvchr_buf_helper((const U8 *) (s), (const U8 *) e, lenp)
#define utf8n_to_uvchr(s, len, lenp, flags) \
Expand Down

0 comments on commit 089fca5

Please sign in to comment.