如何显示法国人的信吗?(How to display french letters?)

2019-09-26 04:49发布

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>

<script language = "VBScript">
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Sub Window_onLoad
  Set dict = CreateObject("Scripting.Dictionary")
  Set file = fso.OpenTextFile ("fr.yml", 1)
  row = 0
  Do Until file.AtEndOfStream
    'Msgbox(file.Readline)
    line = file.Readline
    dict.Add row, line
    row = row + 1
  Loop
  nnn.innerHTML = dict(15)
  hhh.innerHTML = "prêt àprêt à"
End Sub
</script>

<body>
<p id="nnn">éprêt à</p>
<p id="hhh">éprêt à</p>
</body>

在这种代码的<p id="nnn">示出Terminé这样,和<p id="hhh">示出prêt àprêt à正是这样。

我fr.yml文件有16行Terminé

Answer 1:

输入文件( fr.yml )似乎是UTF-8编码。 FileSystemObject方法无法处理的编码,所以你需要使用ADODB.Stream ,如@ Ekkehard.Horner建议:

Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 2 'text
stream.Charset = "utf-8"
stream.LoadFromFile "fr.yml"
For Each line In Split(stream.ReadText, vbNewLine)
  dict.Add row, line
  row = row + 1
Next
stream.Close


Answer 2:

我解决它在我自己通过增加一个参数OpenTextFile()

dim fso: set fso = CreateObject("Scripting.FileSystemObject")
Sub Window_onLoad
  Set dict = CreateObject("Scripting.Dictionary")
  Set file = fso.OpenTextFile ("fr.yml", 1, -1)
  row = 0
  Do Until file.AtEndOfStream
    'Msgbox(file.Readline)
    line = file.Readline
    dict.Add row, line
    row = row + 1
  Loop
  nnn.innerHTML = dict(15)
  hhh.innerHTML = "prêt àprêt à"
End Sub

参考这里



文章来源: How to display french letters?
标签: vbscript hta