[CentOS] escape .c files to html code with bash how?
Bowie_Bailey at BUC.com
Mon Oct 18 12:52:12 EDT 2010
On 10/18/2010 12:34 PM, Jozsef Vadkan wrote:
> i need to encode .c files to html, like on this website:
> i tried to write a bash script for it:
> but it's not working very well :D
> does anyone has a script, that does this?
That script is never going to work right as written. Consider this:
Text to encode: # 123
First, it will replace the space, resulting in: # 123
Next, it will replace the two #s, resulting in: #&#32;123
Next, it will replace the three &s, resulting in:
I'm sure you can see where this is going...
If you want to replace almost every character in a file, you either have
to do it character by character to avoid this problem, or make more
complex regexes to avoid matching stuff that has already been replaced.
What is the eventual use of this program? Do you really need to convert
every character to an entity, or could you leave most of the normal
characters alone and only convert the ones that cause problems?
More information about the CentOS