如何显示法文字母?

How to display french letters?

<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é

您的输入文件 (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

我通过在 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

引用Here