Encodage d'un fichier dans le httpResponse
Bonjour tout le monde,
Mon appli renvoi à la demande du user un fichier csv avec un certain nombre de trucs dedans mais le problème n'est pas là, tout fonctionne très bien
Le souci c'est que les accents, les apostrophes et tout ce genre de caractères spéciaux sont tout moche (genre "é" pour "é") pourtant je le mets bien en UTF8, il y a donc quelque chose qui m'échappe :aie:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Dim fileName As String = Server.MapPath(".\upload\LinesInError_" & Now.ToString("yyyyMMdd_HHmmss") & ".csv")
Dim fi As FileInfo = New FileInfo(fileName)
Dim sw As StreamWriter = fi.AppendText()
Dim row As String = String.Empty
Dim headers As String = String.Empty
For Each entry As Generic.KeyValuePair(Of Integer, Generic.Dictionary(Of String, String)) In RowsInErrorList
For Each field As Generic.KeyValuePair(Of String, String) In entry.Value
headers &= field.Key & ";"
row &= field.Value & ";"
Next
If entry.Key = RowsInErrorList.Keys.First Then sw.WriteLine(headers)
sw.WriteLine(row)
row = String.Empty
sw.Flush()
Next
sw.Dispose()
Response.HeaderEncoding = System.Text.Encoding.UTF8
Response.AppendHeader("Content-Disposition", "attachment; filename=" & fileName)
Response.TransmitFile(fileName)
Response.End() |
Donc si quelqu'un pouvait me montrer la chose qui m'échappe :ccool: