刚才我又仔细核对了临时服务器上生成 html 代码,发现和 Debian 官方网站相比,在 head 里面,缺少了指定 UTF-8 的一行 meta。
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
看了下 Makefile 里面编译 html 脚本:
#######################################################################
# $ make html # update all HTML in $(TMPDIR)
#######################################################################
.PHONY: html
html: $(foreach LX, $(LANGALL), $(TMPDIR)/index.$(LX).html)
$(TMPDIR)/index.%.html: $(MANUAL).%.xml $(ENT_ALL)
@$(call check-command, xsltproc, xsltproc)
-mkdir -p $(TMPDIR)
$(XPINC) --stringparam base.dir $(TMPDIR)/ \
--stringparam html.ext .$*.html \
$(DXSL)/style-html.xsl $<
html 的生成,只与上述命令相关。
查看编译过程中用到的文件 ./xslt/style-html.xsl,
<!-- Since I use xsltproc (not saxon), this is workaround to ensure UTF-8 -->
<xsl:template xmlns="http://www.w3.org/1999/xhtml" name="head.content.generator">
<xsl:param name="node" select="."/>
<meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</xsl:template>
里面已经有了指定字符编码为 UTF-8 的 meta 行.
在编译过程中,是 docbook-xsl 这个包,负责 xml 到 html 的格式转换:“stylesheets for processing DocBook XML to various output formats”
比较 Debian官方网站和临时服务器上生成的 html 源代码,也发现了 docbook-xsl 版本的不同:
Debian官方网站上,用于编译的 docbook-xsl 版本是 1.79.1: "DocBook XSL Stylesheets V1.79.1"
而临时服务器上,这个包比较旧,版本是 1.76.
后单独对这个包进行升级,重新编译,生成的 html 文件里面,已经包含如下这行:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
用 Firefox 浏览器打开,页面正常,问题解决。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Debian 参考手册</title>
<link rel="stylesheet" type="text/css" href="debian-reference.css"/>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="home" href="index.zh-cn.html" title="Debian 参考手册"/>
<link rel="next" href="pr01.zh-cn.html" title="序言"/>
</head>
非常感谢大家反馈问题哈!
atzlinux