forms - 是否有一个函数可以像从表单一样解码编码的 unicode utf-8 字符串?

标签 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>

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

(这是针对汉字“人”...其作为 Rebol 二进制文字的 UTF-8 形式是 #{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

最佳答案

我有一个名为 AltWebForm 的图书馆编码/解码百分比编码的网络表单数据:

do http://reb4.me/r3/altwebform
load-webform "field=%E4%BA%BA"

该库在此处描述:Rebol and Web Forms .

关于forms - 是否有一个函数可以像从表单一样解码编码的 unicode utf-8 字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18331557/

相关文章:

python cgi + 用于运行批处理命令的网络界面?

ruby-on-rails - 如何显示交互式字符限制?

unicode - 变量名称的 clang Unicode 字符

c++ - C++ 标准是否要求对 wchar_t 进行编码?

python - Python 3.2 上缺少 u 字符串?

Python CGI 错误 500 : Premature end of script headers

javascript - 无法在按键时提交表单

Javascript - 如何防止表单发送多个验证检查?

c# - VS 2008 C# 将焦点设置为仅一种形式

mysql - 如何在 Perl 中创建 MySQL 风格的时间戳?