Skip to content

Commit cf7ba1f

Browse files
committed
FEAT: allow DEHEX to accept binary! value
So one can use it to properly url-decode utf-8 sequence, like: ``` >> to-string dehex #{2F666F726D3F763D254335253939} == "/form?v=ř" >> to-string dehex to-binary "%c5%99" == "ř" ``` Related issue: metaeducation/rebol-issues#1986
1 parent 6f73585 commit cf7ba1f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/boot/natives.r

+2-2
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ uppercase: native [
520520
]
521521

522522
dehex: native [
523-
{Converts URL-style hex encoded (%xx) strings.}
524-
value [any-string!] {The string to dehex}
523+
{Converts URL-style hex encoded (%xx) strings. If input is UTF-8 encode, you should first convert it to binary!}
524+
value [any-string! binary!] {The string to dehex}
525525
]
526526

527527
get: native [

src/tests/units/series-test.r3

+9
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ Rebol [
218218

219219
===end-group===
220220

221+
222+
===start-group=== "DEHEX"
223+
224+
--test-- "DEHEX UTF-8 encoded data"
225+
;@@ https://github.com/rebol/rebol-issues/issues/1986
226+
--assert "řek" = to-string dehex to-binary "%c5%99ek"
227+
228+
===end-group===
229+
221230
;-- VECTOR related tests moved to %vector-test.r3
222231

223232
~~~end-file~~~

0 commit comments

Comments
 (0)