Rebol 编程/decode-cgi
外观
< Rebol 编程
DECODE-CGI args
将 CGI 参数字符串转换为设置字和值字符串块。
DECODE-CGI 是一个函数值。
- args -- 从第一个参数字开始。 (类型: any-string)
decode-cgi: func [ {Converts CGI argument string to a block of set-words and value strings.} args [any-string!] "Starts at first argument word." /local block name value here tmp ][ block: make block! 7 parse/all args [ any [ copy name [to #"=" | to #"&" | to end] skip here: ( if tmp: find name #"&" [ here: skip here (offset? tmp name) - 2 clear tmp ] name: to-set-word dehex name either tmp: find block name [ tmp: next tmp if not block? value: first tmp [ change/only tmp reduce [value] ] tmp: first tmp ] [ append tmp: block name ] ) :here [ [copy value to #"&" skip | copy value to end] ( append tmp either none? value [copy ""] [ replace/all dehex replace/all value #"+" #" " crlf newline ] ) ] ] end ] block ]