是否有方法将Unicode字符串数据从Access表转换为UTF-8格式?我之所以问这个问题,是因为我想使用带有希腊语HTTP的ActiveX web浏览器控件。
编辑:
只是为了添加返回URL字符串的函数
Dim tempsql As String
Dim rs As DAO.Recordset
Dim webAddress As String
tempsql = "Select real_address from propertyData"
Set rs = CurrentDb.OpenRecordset(tempsql)
webAddress = "http://maps.googleapis.com/maps/api/staticmap?"
webAddress = webAddress & "center=Athens,Greece&zoom=myzoom&size=800x1200&"
Do While Not rs.EOF
webAddress = webAddress & "markers=color:red%7Clabel: %7C" & rs.Fields(0).Value & "&"
rs.MoveNext
Loop
webAddress = webAddress & "sensor=false"发布于 2015-12-08 02:07:13
以下是Access 2010中包含股票Web浏览器控件的表单中适用的内容

有一个名为GreekWords的表
id word
-- ----
1 Ώπα表单上的一个按钮打开希腊文维基百科页面,这个单词的代码如下:
Option Compare Database
Option Explicit
Private Sub Command1_Click()
Dim word As String, url As String
word = DLookup("word", "GreekWords", "id=1")
url = "http://en.wikipedia.org/wiki/el:" & word
Me.WebBrowser0.ControlSource = "=""" & url & """"
End Sub下面是Wireshark捕获的HTTP请求,显示URL中的Unicode字符确实自动编码为UTF-8,然后是百分比转义(%CE%8F%CF%80%CE%B1):

编辑re:问题更新
当涉及查询字符串时,Web浏览器控件的行为似乎有所不同。当我试着
Option Compare Database
Option Explicit
Private Sub Command1_Click()
Dim word As String, url As String
word = DLookup("word", "GreekWords", "id=1")
url = "http://localhost:8080/echo.php?arg=test%7C" & word
Me.WebBrowser0.ControlSource = "=""" & url & """"
End Sub发送的HTTP请求是
GET /echo.php?arg=test%7C?pa HTTP/1.1\r\n因此,如果Unicode字符出现在querystring中,那么我们确实需要进行自己的编码:
Option Compare Database
Option Explicit
Private Sub Command1_Click()
Dim word As String, url As String
word = DLookup("word", "GreekWords", "id=1")
' URL encoding, ref: http://stackoverflow.com/a/28923996/2144390
Dim ScriptEngine As Object, encodedWord As String
Set ScriptEngine = CreateObject("scriptcontrol")
ScriptEngine.Language = "JScript"
encodedWord = ScriptEngine.Run("encodeURIComponent", word)
Set ScriptEngine = Nothing
url = "http://localhost:8080/echo.php?arg=test%7C" & encodedWord
Me.WebBrowser0.ControlSource = "=""" & url & """"
End Sub它发送
GET /echo.php?arg=test%7C%CE%8F%CF%80%CE%B1 HTTP/1.1\r\nhttps://stackoverflow.com/questions/34123205
复制相似问题