经典ASP的的Request.Form正在下降8位字符 - 有一个简单的方法prevent呢? [英] Classic ASP's Request.Form is dropping an 8-bit character -- is there a simple way to prevent this?

查看:194
本文介绍了经典ASP的的Request.Form正在下降8位字符 - 有一个简单的方法prevent呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

矿山使用的是经典的ASP脚本来处理从第三方支付处理器形式(这是启动在客户的网站上信用卡事务序列中的最后一步,的一个客户去了三阶方的网站,然后返回到客户端的位点)。

A client of mine is using a Classic ASP script to process a form from a third-party payment processor (this is the last step in a credit-card-transaction sequence that starts at the client's website, goes to the third-party site, and then returns to the client's site).

客户端处于奥地利并且当字段之一包括一个8位的字符(例如,当该字段的值是Österreich)中,O是简单地丢弃时我检索字段中的标准方法的价值;例如:

The client is in Austria and when one of the fields includes an 8-bit character (e.g., when the field value is Österreich), the Ö is simply dropped when I retrieve the value of the field in the standard way; e.g.:

fieldval = Request.Form("country")
If fieldval = "sterreich" Then
    ' Code here will execute
End If

字面值,该第三方网页的发布是%D6sterreich ,其中我觉得的建议,POST正在连接$ C $光盘UTF-8。

The literal value that the third-party page is POSTing is %D6sterreich, which I think suggests that the POST is being encoded in UTF-8.

POST请求具有以下可能相关的标题:

The POST request has the following possibly-relevant headers:


  • 接收字符集:ISO-8859-1,UTF-8,Q = 0.7 *; Q = 0.7

  • 内容类型:应用程序/ x-WWW的形式urlen codeD

  • Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  • Content-Type: application/x-www-form-urlencoded

我决不是一个字符编码的专家,这是我第一次真正做任何与经典ASP,所以我有点狼狈不堪。

I'm by no means a character-encoding expert and this is the first time I've really done anything with Classic ASP, so I'm kind of flummoxed.

从一些谷歌搜索,并因此搜索,我已经添加了以下到处理POST页:

From some Googling and searching SO, I've added the following to the page that processes the POST:

<%@ Codepage=65001 %>
<%
Response.CharSet = "UTF-8"
Response.Codepage = 65001
%>

但它没有任何区别 - 我还是失去最初的8位字符。有很简单的东西,我只是不知道呢?

But it doesn't make any difference -- I still lose that initial 8-bit character. Is there something really simple that I'm just not aware of?

推荐答案

原来我打算这个错误的方向。有问题的ASP文件本身的连接使用UTF-8 $ C $的CD,这是隐式设置响应codePAGE到65001 - 换句话说,明确加入 codePAGE 指令并没有区别 - 事实上的的UTF-8编码是问题的根源

Turns out I was going the wrong direction with this. The ASP file in question was itself encoded in UTF-8, which was implicitly setting Response.CodePage to 65001 -- in other words, explicitly adding a CODEPAGE directive made no difference -- and in fact the UTF-8 encoding was the source of the problem.

当我重新连接codeD文件到Windows 1252,问题就消失了。我是pretty无知一般的字符编码​​,但我认为在事后的%D6 在POST应该是我的线索 - 如果我开始认识事物正确,单字节 0xD6 是的的一个有效的UTF-8字符。也许有人更熟悉这些东西可以证实或否认这一点。

When I re-encoded the file to Windows-1252, the problem disappeared. I'm pretty ignorant of character encodings in general, but I think in retrospect the %D6 in the POST should have been my clue -- if I'm starting to understand things rightly, the single byte 0xD6 is not a valid UTF-8 character. Maybe someone more familiar with these things could confirm or deny this.

这篇关于经典ASP的的Request.Form正在下降8位字符 - 有一个简单的方法prevent呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆