是否有一个函数来解码编码的unicode utf-8字符串,如表格?

Way*_*Cui 5 forms unicode cgi rebol rebol3

我想用html表单和Rebol cgi存储一些数据.我的表单看起来像这样:

<form action="test.cgi" method="post" >

     Input:

     <input type="text" name="field"/>
     <input type="submit" value="Submit" />

</form>
Run Code Online (Sandbox Code Playgroud)

但是对于像中文这样的unicode字符,我得到了具有百分号的数据的编码形式%E4%BA%BA.

(这是为汉字"人"...它的UTF-8形式为Rebol二进制文字是#{E4BABA})

系统中是否有一个功能,或者现有的库可以直接解码? dehex似乎目前不包括这种情况.我正在通过删除百分号并构造相应的二进制文件来手动解码,如下所示:

data: to-string read system/ports/input
print data

;-- this prints "field=%E4%BA%BA"

k-v: parse data "="
print k-v

;-- this prints ["field" "%E4%BA%BA"]

v: append insert replace/all k-v/2 "%" "" "#{" "}"
print v

;-- This prints "#{E4BABA}" ... a string!, not binary!
;-- LOAD will help construct the corresponding binary
;-- then TO-STRING will decode that binary from UTF-8 to character codepoints

write %test.txt to-string load v
Run Code Online (Sandbox Code Playgroud)

rgc*_*ris 3

我有一个名为AltWebForm 的库,它可以对百分比编码的 Web 表单数据进行编码/解码:

do http://reb4.me/r3/altwebform
load-webform "field=%E4%BA%BA"
Run Code Online (Sandbox Code Playgroud)

该库的描述如下:Rebol 和 Web Forms