CSV下载的外来字符编码问题

时间:2013-10-07 13:32:13

标签: utf-8 vbscript character-encoding

我对ASP页面使用UTF8编码。我想为我的网站实现CSV下载功能。以下是我的回复设置

With Response
    .Buffer = true
    .Expires = 0
    .Clear
    .Charset = "UTF-8"
    .CodePage = 65001
    .AddHeader "Content-Type", "text/html;charset=UTF-8"
    .AddHeader "content-encoding", "UTF-8"
    .AddHeader "content-disposition", "attachment; filename=""AgedDebtors.csv"""
End With

为响应标头设置了编码,我仍然在生成的CSV中编码外来字符。为此尝试了一些事情,但未能做到正确。请让我知道我在这里缺少什么

1 个答案:

答案 0 :(得分:0)

  Set stream = CreateObject("ADODB.Stream")
  stream.Open
  stream.Type     = 2 'text
  stream.Position = 0
  stream.Charset  = "utf-8"
  stream.WriteText str

您可能希望将转换后的流保存到新文件中,因此请写下此

  stream.SaveToFile filename, 2

关闭流使用

  stream.Close