关于“使用xmlspy编写xsl文件时候,在xsl解释xml文件的时候总是使用utf-16编码”的解决办法

使用xmlspy编写xsl文件时候,当使用如下编码时,在xsl解释xml文件的时候总是使用UTF-16编码方式

1.   xsl文件

<?xml version="1.0" encoding="gb2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>

//这里虽然指明了显示编码,但是xmlspy生成的xsl解释文件会另在此行之前加上utf-16的编码方式而另此处的指示无效,解决办法如下:
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/> </head>

2.    xsl解释xml文件后输出文件的源代码

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#0099ff">

3.   解决办法:把xsl文件改写成如下形式

<?xml version="1.0" encoding="gb2312"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<head>
<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>
</head>
<body bgcolor="#0099ff">

在<head></head>之前加上<META http-equiv="Content-Type" content="text/html; charset=gb2312"/>,这样xsl解释xml文件生成的文件的源代码就会是如下形式

<html>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#0099ff">

这样编码方式就在utf-16之前给改过来了,客户端也可以正常显示gb2312的中文了

                                                                                                          benchunyang8@hotmail.com  #

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值