entities2literals.pl
来自「php 开发的内容管理系统」· PL 代码 · 共 277 行
PL
277 行
#!/usr/bin/env perl# Takes STDIN and converts Converts hexadecimal, decimal and named HTML# entities to their respective literals.## Usage: perl entities2literals.pl < file_to_convert [> outfile]# Reference: http://www.w3.org/TR/REC-html40/sgml/entities.html# Copyright 2005 脝var Arnfj枚r冒 Bjarmason <avarab@gmail.com> No rights reserveduse encoding 'utf8';use strict;my $file = join /\n/, <>;$file =~ s/&#(\d+);/chr $1/eg;$file =~ s/&#x([0-9a-fA-F]+);/chr hex $1/eg;while (<DATA>) { chomp; my ($number, $entity) = split / +/; $file =~ s/&$entity;/chr $number/eg;}print $file;__DATA__34 quot38 amp60 lt62 gt160 nbsp161 iexcl162 cent163 pound164 curren165 yen166 brvbar167 sect168 uml169 copy170 ordf171 laquo172 not173 shy174 reg175 macr176 deg177 plusmn178 sup2179 sup3180 acute181 micro182 para183 middot184 cedil185 sup1186 ordm187 raquo188 frac14189 frac12190 frac34191 iquest192 Agrave193 Aacute194 Acirc195 Atilde196 Auml197 Aring198 AElig199 Ccedil200 Egrave201 Eacute202 Ecirc203 Euml204 Igrave205 Iacute206 Icirc207 Iuml208 ETH209 Ntilde210 Ograve211 Oacute212 Ocirc213 Otilde214 Ouml215 times216 Oslash217 Ugrave218 Uacute219 Ucirc220 Uuml221 Yacute222 THORN223 szlig224 agrave225 aacute226 acirc227 atilde228 auml229 aring230 aelig231 ccedil232 egrave233 eacute234 ecirc235 euml236 igrave237 iacute238 icirc239 iuml240 eth241 ntilde242 ograve243 oacute244 ocirc245 otilde246 ouml247 divide248 oslash249 ugrave250 uacute251 ucirc252 uuml253 yacute254 thorn255 yuml338 OElig339 oelig352 Scaron353 scaron376 Yuml402 fnof710 circ732 tilde913 Alpha914 Beta915 Gamma916 Delta917 Epsilon918 Zeta919 Eta920 Theta921 Iota922 Kappa923 Lambda924 Mu925 Nu926 Xi927 Omicron928 Pi929 Rho931 Sigma932 Tau933 Upsilon934 Phi935 Chi936 Psi937 Omega945 alpha946 beta947 gamma948 delta949 epsilon950 zeta951 eta952 theta953 iota954 kappa955 lambda956 mu957 nu958 xi959 omicron960 pi961 rho962 sigmaf963 sigma964 tau965 upsilon966 phi967 chi968 psi969 omega977 thetasym978 upsih982 piv8194 ensp8195 emsp8201 thinsp8204 zwnj8205 zwj8206 lrm8207 rlm8211 ndash8212 mdash8216 lsquo8217 rsquo8218 sbquo8220 ldquo8221 rdquo8222 bdquo8224 dagger8225 Dagger8226 bull8230 hellip8240 permil8242 prime8243 Prime8249 lsaquo8250 rsaquo8254 oline8260 frasl8364 euro8465 image8472 weierp8476 real8482 trade8501 alefsym8592 larr8593 uarr8594 rarr8595 darr8596 harr8629 crarr8656 lArr8657 uArr8658 rArr8659 dArr8660 hArr8704 forall8706 part8707 exist8709 empty8711 nabla8712 isin8713 notin8715 ni8719 prod8721 sum8722 minus8727 lowast8730 radic8733 prop8734 infin8736 ang8743 and8744 or8745 cap8746 cup8747 int8756 there48764 sim8773 cong8776 asymp8800 ne8801 equiv8804 le8805 ge8834 sub8835 sup8836 nsub8838 sube8839 supe8853 oplus8855 otimes8869 perp8901 sdot8968 lceil8969 rceil8970 lfloor8971 rfloor9001 lang9002 rang9674 loz9824 spades9827 clubs9829 hearts9830 diams
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?