2011-09-22

emacs quiz: replacing html entities with unicode char

here's a emacs quiz for you advanced emacs users out there.

I have a file with content like this:

…
<tr><td>pound</td><td>&#163;</td><td>pound sign, U+00A3</td></tr>
<tr><td>curren</td><td>&#164;</td><td>currency sign, U+00A4</td></tr>
<tr><td>yen</td><td>&#165;</td><td>yen sign = yuan sign, U+00A5</td></tr>
<tr><td>brvbar</td><td>&#166;</td><td>broken bar = broken vertical bar, U+00A6</td></tr>
<tr><td>sect</td><td>&#167;</td><td>section sign, U+00A7</td></tr>
<tr><td>uml</td><td>&#168;</td><td>diaeresis = spacing diaeresis, U+00A8</td></tr>
<tr><td>copy</td><td>&#169;</td><td>copyright sign, U+00A9</td></tr>
…

I need it to be like this:

…
<tr><td>pound</td><td>£</td><td>pound sign, U+00A3</td></tr>
<tr><td>curren</td><td>¤</td><td>currency sign, U+00A4</td></tr>
<tr><td>yen</td><td>¥</td><td>yen sign = yuan sign, U+00A5</td></tr>
<tr><td>brvbar</td><td>¦</td><td>broken bar = broken vertical bar, U+00A6</td></tr>
<tr><td>sect</td><td>§</td><td>section sign, U+00A7</td></tr>
<tr><td>uml</td><td>¨</td><td>diaeresis = spacing diaeresis, U+00A8</td></tr>
<tr><td>copy</td><td>©</td><td>copyright sign, U+00A9</td></tr>
…

How would you do it using emacs's power?

I'll post a solution in 2 days.

2011-09-24 Answer at: Emacs Lisp: Replacing HTML Entities with Unicode Characters.