How could ASP server-side code corrupt a smart quo

2019-07-19 07:54发布

My company just converted many columns from varchar to nvarchar.

Now it seems that when we render a smart quote (i.e. ALT+0146 ’) to the screen and then send it back to the SQL Server 2000 database for persistence, the smart quote gets corrupted to - ’ -.

My Question:

How could ASP server-side code corrupt a smart quote ’ ?

EDIT: It appears that my question is similar to this one. Incidentally, Powerpoint content introduced the smart quote into the mix. However as I said before, I'm dealing with an ASP page, whereas the referenced question pertains to a PHP page.

EDIT: The server-side directive CODEPAGE=65001 makes the page render correctly, but it still posts content as 'Western European' on a Windows 2000 box. Does anyone know why?

4条回答
Anthone
2楼-- · 2019-07-19 08:16

It looks like something is doing an implicit conversion between ANSI and Unicode (and choosing the wrong code page in the process). You may need to do the conversion manually and supply the correct code page. It's hard to say without seeing the code.

查看更多
男人必须洒脱
3楼-- · 2019-07-19 08:23

While you do need to tell the server which encoding to use, have you told the client what the page encoding is? If not, the client will happily post in whatever encoding the user last explicitly chose, or a system default encoding, which is likely to be western european on most US or Western European machines.

In your html, do you have something like this in your <head> ?

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

You can also ask the server to send this explicitly in your Response.Headers. Although I think it's a good idea to send it in the HTTP headers, it's helpful to include it in the HTML as well for people who decide to save the document locally for whatever reason.

查看更多
劳资没心,怎么记你
4楼-- · 2019-07-19 08:26

VBScript might mangle the Unicode characters; especially on older versions of IIS (i.e IIS 5.0 on Windows Server 2000).

In my case, a For Each construct was to blame.

Here's some example code that executes after a POST:

Response.Write Request.Form("selOptions")(0) ' A-OK! - Displays Unicode characters fine!  
For Each sOption in Request.Form("selOptions")
  Response.Write sOption ' Bad! Unicode characters are mangled!  
Next

As always, your mileage may vary.

查看更多
手持菜刀,她持情操
5楼-- · 2019-07-19 08:29

Take a look at this:

http://support.microsoft.com/kb/232580

You may want to set your Code Page in the ASP so you don't get hokey characters.

查看更多
登录 后发表回答