English 中文(简体)
Is there anything to convert HTML special characters in files to normal characters?
原标题:

I have some source code files which came to me by an HTML output, so they re pretty unusable.

I have things like this:

%include "macros.mac"

Which should be:

%include "macros.mac"

Is there any script (sh, perl, batch, ...) to convert every file (there are about 200) to the appropriate characters? Characters include & lt;, & gt;, ... (I put an space in the middle so that it wont convert them to < and >.

Thank you, it s very appreciated.

最佳回答

If it is just about the four &"<> characters, sed(1) could help:

sed  s/&quot;/"/g; s/&lt;/</g; s/&gt;/>/g; s/&amp;/&/g 

Update: My original proposal was the following and had a bug:

sed  s/&amp;/&/g; s/&quot;/"/g; s/&lt;/</g; s/&gt;/>/g 

This would convert "&amp;gt;" into ">" which is wrong.

问题回答

you can try a tool like windows grep or textcrawler for this





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签