Personal tools
You are here: Home メンバー 菊地時夫 メモ あれは HTML entity というのか
Document Actions

あれは HTML entity というのか

by 菊地時夫 posted at 2008-05-22 15:47 last modified 2008-05-22 15:55

&Xyz; とか書いて、ラテン文字とか鍵カッコとか、入力できなかったり文字コード集合に無かったり、タグと間違えないようにするやつ。

Python では htmlentitydefs というところに表(辞書)があるので、これを使えばよろしい。

プログラム例:

  from htmlentitydefs import name2codepoint as table
  def decode(s):
      def r(m):
          x = m.group(1)
          if x.isdigit():
              return unichr(int(x))
          elif x in table:
              return unichr(table[x])
          return x
      #
      s = unicode(s)
      return re.sub(r'&(.*?);', r, s)

Category(s)
なんでも
The URL to Trackback this entry is:
http://sango.lab.tkikuchi.net/Members/tkikuchi/30e130e2/3042308c306f-html-entity-306830443046306e304b/tbping
« December 2010 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
About this blog
メモ代わりのブログ
Recent entries
JIS を戻すって tkikuchi 2010-06-14
ゼネラリスト tkikuchi 2010-04-26
Solaris 10 で 64bit tkikuchi 2010-04-11
なんかマヌケ? tkikuchi 2010-02-22
Oracle + ASP.NET なんですね tkikuchi 2010-01-28
Recent comments
Re:lock できないので tkikuchi 2009-06-03
Re:挨拶用メモ tkikuchi 2009-05-27
Re:挨拶用メモ knakahasi 2009-05-04
Re:Xgrid (続編) tkikuchi 2008-10-09
PILでのグラフ出力 ytoshio 2008-03-06
Categories
なんでも
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: