GBK和GB2312编码区域对比
来源:岁月联盟
时间:2009-10-15
GB2312:高位A1-F7,低位A1-FE(图中深黑色方块部分)
GBK:高位81-FE ,低位 40-7E、80-FE(图中浅黑色方块部分)
GB2312是GBK的子集,他们编码区域都不大。
图是用html+js画出来的,顺便公布一下代码
bg.gif是32*32的透明背景图片,右边和下边有1像素描边
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GB2312与GBK编码覆盖图示</title>
<style>
#bg{
background-color:#eee;
background-image:url(bg.gif);
height:512px;
width:512px;
position:absolute;
left:50px;
top:10px;
z-index:5;
}
#bgshadow{
background:#666;
height:512px;
width:512px;
position:absolute;
left:55px;
top:15px;
}
body{
margin:0;
background:#a7a7a7;
}
.ruler{
position:absolute;
font-family: "Courier New", Courier, monospace;
font-size: 12px;
border:1px solid #333;
background:#fff;
padding:0 1px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<div id="bgshadow"></div>
<div id="bg"></div>
<div class="ruler" style="top:512px;left:10px;">0x00</div>
<div class="ruler" style="top:532px;left:40px;">0x00</div>
<div class="ruler" style="top:385px;left:10px;">0x40</div>
<div class="ruler" style="top:257px;left:10px;">0x80</div>
<div class="ruler" style="top:193px;left:10px;">0xA0</div>
<div class="ruler" style="top:5px;left:10px;">0xFF</div>
<div class="ruler" style="top:532px;left:552px;">0xFF</div>
<div class="ruler" style="top:532px;left:290px;">0x80</div>
<div class="ruler" style="top:532px;left:354px;">0xA0</div>
</body>
<script>
var topMargin = 10;
var leftMargin = 50;
function buildSquare (high, low, color) {
var el = document.createElement('div');
var style = el.style;
style.background = color;
style.zIndex = '10';
style.position = 'absolute';
style.filter = 'alpha(opacity=50)';
style.opacity = '0.5';
style.width = ((low[1] - low[0]) * 2) + 'px';
style.height = ((high[1] - high[0]) * 2) + 'px';
style.left = (leftMargin + low[0] * 2) + 'px';
style.top = (topMargin + (0xff - high[1] + 1) * 2) + 'px';
document.body.appendChild(el);
}
//build gb2312
buildSquare([0xa1,0xf7], [0xa1,0xfe], 'black');
//build gbk
buildSquare([0x81,0xfe], [0x80,0xfe], 'black');
buildSquare([0x81,0xfe], [0x40,0x7e], 'black');
</script>
</html>
下一篇:HTML5标准最新技术先知