When entering bugs in our local bug reporting system, I forget to enter reserved HTML characters such as < (less-than) and > (greater-than) as character codes < and >. When I submit my bugs, our server swallows up these reserved characters and my bug reports look rather silly (mind you, a lot of bugs are silly to start with). A similar problem happens when I write a blog with code fragments containing these characters or if I want my source code to be indented nicely. So, here's a simple Javascript Web page to handle these conversions.
The nice bit of code (IMHO) is using string.slice()
in the regular expression to replace tabs with a user-specified number of space characters: sIn.replace(/\t/g, ' '.slice(0,iTabSpace)).
No comments:
Post a Comment