これは初めてですが、icsファイルへの生成スクリプトがあり、iCalとOutlookで100%動作しますが、エンコーディングを修正する方法がわかりません。
データベースに北欧の æ ø å (æ ø å) を含むテキストがある場合、文字は ? として取得されます。iso-8859-1を使用するようにこれを設定するのを手伝ってくれませんか。
または、文字を html タグ (æ ø å) に置き換える 6 置換コードを作成する必要がありますか!?
私のコードは
Imports System.Data.OleDb
Imports System.Data
Imports RF.Event2
Partial Class _new
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
End If
End Sub
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ical As New iCalendar()
Dim strConnection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStr").ConnectionString)
Dim strQuery As String = String.Empty
strQuery = "SELECT * FROM [Events] WHERE ([EventType]='K' OR [EventType]='E' OR [EventType]='T') ORDER BY [EventDate] ASC"
Dim daEvents As New OleDbDataAdapter(strQuery, strConnection)
Dim dtEvents As New DataTable
strConnection.Open()
daEvents.Fill(dtEvents)
strConnection.Close()
If (dtEvents.Rows.Count > 0) Then
For i As Integer = 0 To dtEvents.Rows.Count - 1
Dim ev As New [Event]()
ev.Title = dtEvents.Rows(i)("EventHome")
ev.Description = dtEvents.Rows(i)("EventNote")
ev.Location = dtEvents.Rows(i)("EventPlace")
ev.StartTime = DateTime.Parse(dtEvents.Rows(i)("EventDate"))
ev.EndTime = DateTime.Parse(dtEvents.Rows(i)("EventDate").AddMinutes(90))
ical.Events.Add(ev)
Next
End If
' Set the content-type of the response and file name
' so Windows knows how to handle the response.
Context.Response.Buffer = True
Context.Response.ContentType = "text/calendar"
Context.Response.ContentEncoding = Encoding.GetEncoding("iso-8859-1")
Context.Response.Charset = "iso-8859-1"
Context.Response.AddHeader("content-disposition", "inline;filename=Sport.ics")
' Write the bytes of the iCalendar item output to the resonse stream
Context.Response.BinaryWrite(New System.Text.ASCIIEncoding().GetBytes(ical.Output))
Context.Response.[End]()
'Dim enc As System.Text.Encoding = System.Text.Encoding.GetEncoding("iso-8859-1")
End Sub
End Class