Click to See Complete Forum and Search --> : Why do some Chinese Words become ?


Robert Chu
02-06-2010, 03:12 AM
Hello,
I write a program to download some Chinese words from database. I use deubg to find that these word are correct in the function parameter. But when download to Client Side as a 'csv' file, some words become '?'. The follwing is the code. What's the problem ?

Sub DownloadFile(ByVal WebForm As System.Web.UI.Page, ByVal FileNameWhenUserDownload As String, ByVal FileBody As String)
WebForm.Response.ClearHeaders()
WebForm.Response.Clear()
WebForm.Response.Expires = 0
WebForm.Response.Buffer = True
WebForm.Response.AddHeader("Accept-Language", "zh-tw")

WebForm.Response.AddHeader("content-disposition", "attachment; filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(FileNameWhenUserDownload, System.Text.Encoding.UTF8) & Chr(34))
WebForm.Response.ContentType = "Application/octet-stream"

WebForm.Response.ContentEncoding = System.Text.Encoding.GetEncoding("big5")
Dim strUtf8 As Byte() = Encoding.Unicode.GetBytes(FileBody)
Dim strBig5 As Byte() = Encoding.Convert(Encoding.Unicode, Encoding.Default, strUtf8)
WebForm.Response.BinaryWrite(strBig5)
WebForm.Response.End()
End Sub