html编码后台转换,HTML编码转换、HTML部分实体
网页中的字符编码:
1、编码转换(to Unicode)
(程序代码来源于网络)
Js版
test = "你好abc"
str = ""
for( i=0; i
{
temp = test.charCodeAt(i).toString(16);
str += "\\u"+ new Array(5-String(temp).length).join("0") +temp;
}
document.write (str)
vbs版
Function Unicode(str1)
Dim str,temp
str = ""
For i=1 to len(str1)
temp = Hex(AscW(Mid(str1,i,1)))
If len(temp) < 5 Then temp = right("0000" & temp, 4)
str = str & "\u" & temp
Next
Unicode = str
End Function
Function htmlentities(str)
For i = 1 to Len(str)
char = mid(str, i, 1)
If Ascw(char) > 128 then
htmlentities = htmlentities & "" & Ascw(char) & ";"
Else
htmlentities = htmlentities & char
End if
Next
End Function
coldfusion版
function nochaoscode(str)
{
var new_str = “”;
for(i=1; i lte len(str);i=i+1){
if(asc(mid(str,i,1)) lt 128){
new_str = new_str & mid(str,i,1);
}else{
new_str = new_str & “#” & asc(mid(str,i,1));
}
}
return new_str;
}
附:
在php中我们可以用mbstring的mb_convert_encoding函数实现这个正向及反向的转化。 如:
mb_convert_encoding ("你好", "HTML-ENTITIES", "gb2312"); //输出:你好
mb_convert_encoding ("你好", "gb2312", "HTML-ENTITIES"); //输出:你好
如果需要对整个页面转化,则只需要在php文件的头部加上这三行代码:
mb_internal_encoding("gb2312"); // 这里的gb2312是你网站原来的编码
mb_http_output("HTML-ENTITIES");
ob_start(‘mb_output_handler‘);
如果没有打开mbstring扩展,可以参考coolcode.cn上的这两篇文章:
在任意字符集下正常显示网页的方法
在任意字符集下正常显示网页的方法(续)
2、HTML实体
HTML 4.01 支持 ISO 8859-1 (Latin-1) 字符集。
提示 实体名是区分大小写的。
备注 同一个符号,可以用“实体名称”和“实体编号”两种方式引用,“实体名称”的优势在于便于记忆,但不能保证所有的浏览器都能顺利识别它,而“实体编号”则没有这种担忧,但它实在不方便记忆。
ASCII中部分实体的新名字
显示
描述
实体名称
实体编号
"
quotation mark
"
"
‘
apostrophe
' (IE下无效)
'
&
ampersand
&
&
<
less-than
<
<
>
greater-than
>
>
ISO 8859-1 符号实体
显示
描述
实体名称
实体编号
non-breaking space
¡
inverted exclamation mark
¡
¡
¤
currency
¤
¤
¢
cent
¢
¢
£
pound
£
£
¥
yen
¥
¥
¦
broken vertical bar
¦
¦
§
section
§
§
¨
spacing diaeresis
¨
¨
©
copyright
©
©
a
feminine ordinal indicator
ª
ª
«
angle quotation mark (left)
«
«
negation
¬
¬
-
soft hyphen
®
registered trademark
®
®
™
trademark
™
™
ˉ
spacing macron
¯
¯
°
degree
°
°
±
plus-or-minus
±
±
2
superscript 2
²
²
3
superscript 3
³
³
′
spacing acute
´
´
μ
micro
µ
µ
paragraph
¶
¶
·
middle dot
·
·
spacing cedilla
¸
¸
1
superscript 1
¹
¹
o
masculine ordinal indicator
º
º
»
angle quotation mark (right)
»
»
fraction 1/4
¼
¼
fraction 1/2
½
½
fraction 3/4
¾
¾
inverted question mark
¿
¿
×
multiplication
×
×
÷
division
÷
÷
ISO 8859-1 字符实体
显示
描述
实体名称
实体编号
À
capital a, grave accent
À
À
Á
capital a, acute accent
Á
Á
Â
capital a, circumflex accent
Â
Â
Ã
capital a, tilde
Ã
Ã
Ä
capital a, umlaut mark
Ä
Ä
Å
capital a, ring
Å
Å
Æ
capital ae
Æ
Æ
Ç
capital c, cedilla
Ç
Ç
È
capital e, grave accent
È
È
É
capital e, acute accent
É
É
Ê
capital e, circumflex accent
Ê
Ê
Ë
capital e, umlaut mark
Ë
Ë
Ì
capital i, grave accent
Ì
Ì
Í
capital i, acute accent
Í
Í
Î
capital i, circumflex accent
Î
Î
Ï
capital i, umlaut mark
Ï
Ï
Ð
capital eth, Icelandic
Ð
Ð
Ñ
capital n, tilde
Ñ
Ñ
Ò
capital o, grave accent
Ò
Ò
Ó
capital o, acute accent
Ó
Ó
Ô
capital o, circumflex accent
Ô
Ô
Õ
capital o, tilde
Õ
Õ
Ö
capital o, umlaut mark
Ö
Ö
Ø
capital o, slash
Ø
Ø
ù
capital u, grave accent
Ù
Ù
ú
capital u, acute accent
Ú
Ú
capital u, circumflex accent
Û
Û
ü
capital u, umlaut mark
Ü
Ü
Y
capital y, acute accent
Ý
Ý
T
capital THORN, Icelandic
Þ
Þ
small sharp s, German
ß
ß
à
small a, grave accent
à
à
á
small a, acute accent
á
á
a
small a, circumflex accent
â
â
small a, tilde
ã
ã
small a, umlaut mark
ä
ä
small a, ring
å
å
small ae
æ
æ
small c, cedilla
ç
ç
è
small e, grave accent
è
è
é
small e, acute accent
é
é
ê
small e, circumflex accent
ê
ê
small e, umlaut mark
ë
ë
ì
small i, grave accent
ì
ì
í
small i, acute accent
í
í
small i, circumflex accent
î
î
small i, umlaut mark
ï
ï
e
small eth, Icelandic
ð
ð
small n, tilde
ñ
ñ
ò
small o, grave accent
ò
ò
ó
small o, acute accent
ó
ó
small o, circumflex accent
ô
ô
small o, tilde
õ
õ
small o, umlaut mark
ö
ö
small o, slash
ø
ø
ù
small u, grave accent
ù
ù
ú
small u, acute accent
ú
ú
small u, circumflex accent
û
û
ü
small u, umlaut mark
ü
ü
y
small y, acute accent
ý
ý
t
small thorn, Icelandic
þ
þ
small y, umlaut mark
ÿ
ÿ
其它一些 HTML 所支持的实体
显示
描述
实体名称
实体编号
Œ
capital ligature OE
Œ
Œ
œ
small ligature oe
œ
œ
Š
capital S with caron
Š
Š
š
small S with caron
š
š
Ÿ
capital Y with diaeres
Ÿ
Ÿ
ˆ
modifier letter circumflex accent
ˆ
ˆ
˜
small tilde
˜
˜
en space
em space
thin space
zero width non-joiner
zero width joiner
left-to-right mark
right-to-left mark
–
en dash
–
–
—
em dash
—
—
‘
left single quotation mark
‘
‘
’
right single quotation mark
’
’
‚
single low-9 quotation mark
‚
‚
“
left double quotation mark
“
“
”
right double quotation mark
”
”
„
double low-9 quotation mark
„
„
†
dagger
†
†
‡
double dagger
‡
‡
…
horizontal ellipsis
…
…
‰
per mille
‰
‰
‹
single left-pointing angle quotation
‹
‹
›
single right-pointing angle quotation
›
›
€
euro
€
€
参考:
html编码后台转换,HTML编码转换、HTML部分实体相关推荐
- shell 批量转换文件编码
相信大家在平时的跨平台编程中碰到过文件编码问题,比如在Windows代码字符编码方式是GB2312,然而转到Linux却只支持utf-8,虽然对代码部分没啥影响,但是很多中文注释部分,却一片乱码,很让 ...
- Java工具类-转换字符编码
package common; /***字符串处理公用类 */ public class DealString {/*** 转换字符编码 由"iso-8859-1"西文转换为简体中 ...
- python utf-8编码转换中文_python实现unicode转中文及转换默认编码的方法
本文实例讲述了python实现unicode转中文及转换默认编码的方法.分享给大家供大家参考,具体如下: 一.在爬虫抓取网页信息时常需要将类似"\u4eba\u751f\u82e6\u77e ...
- 使用vim转换文件编码
使用命令:set fileencoding=utf-8设置目标文件编码,然后保存 附:vim编码原理 Vim 有四个跟字符编码方式有关的选项,encoding.fileencoding.fileenc ...
- 格式化输出,运算符,编码,字符串(索引,切片,大小写转换等等)
格式化输出%s和format{} , 运算符 , 编码 , 字符串(索引,切片,大小写转换,拉长字符,去空格,替换,切割,格式化输出format , count数数 , find查找 , index求 ...
- pcm 采样率转换_PCM编码与Waveform音频文件(.wav)格式详解
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是PCM编码及Waveform音频文件格式. 嵌入式里有时候也会和音频打交道,比如最近特别火的智能音箱产品,离不开前端的音频信号采集.降噪 ...
- python中字符编码使用_python中字符编码是什么?如何转换字符?
屏幕前我们看到的文字,在计算机中也是这样表示吗?事实上,我们所有的信息电脑是无法直接理解的,同样我们所要表达的信息,计算机也不能看懂.这就需要架起一个理解的桥梁,也就是编码帮助我们相互之间进行翻译.今 ...
- 一网打尽中文编码转换---6种编码30个方向的转换
一网打尽中文编码转换--6种编码30个方向的转换 1.问题提出 在学编程序时,曾经有人问过"你可以编一个记事本程序吗?"当时很不屑一顾,但是随着学习MFC的深入,了解到记事本程序也 ...
- PHP类UTF8编码内的繁简转换-繁体-简体
js网页繁体简体转换 均只支持 UTF8 文本,所以如果获得的来源是 $_GET 的话, 就有必要转换一下编码了.用到的函数是: $str = $_GET['str']; // 简体到utf8 $st ...
最新文章
- 读 博 失 败 的 10 大 作 死 方 法
- 如何把自己打造成技术圈的 papi 酱
- 需求调研计划_拆书营销管理 实施营销调研和预测需求
- 地大计算机学院教授,张静(地大教授)
- 电子网络发票应用系统网络不通_深度强化学习在典型网络系统中的应用综述
- leetcode 1293. Shortest Path in a Grid with Obstacles Elimination | 1293. 网格中的最短路径(BFS)
- 手动加载spring, ApplicationContext怎么销毁
- [2021.1.27多校省选模拟10]染色(min-max容斥/二项式反演)
- linux部署tomcat项目404_一个tomcat下部署多个项目或一个服务器部署多个tomcat
- Orleans学习总结(一)--入门认识
- 第二章:Improving On User Commands--22.显示不同时区的时间
- php if多条件_通过几个案例掌握shell编程条件分支结构
- 43. Element hasAttributes() 方法
- 超大图像的二值化方法
- 如何用计算机截部分屏,电脑如何长屏幕的截图?电脑截取长屏的方法
- 有哪些连接oracle的工具,连接oracle数据库工具有哪些
- iPad2 3G版 5.1.1降级到4.3.3(需要4.3.3SHSH备份)
- element-ui 导航栏三级
- MySQL查询与数据库设计 #万能公式 #思维导图 #MySQL查询 #数据库设计规范 #第二部分
- 一寸照片多大?你知道一寸照片的尺寸吗?