Forum OpenACS Q&A: trivial proc to escape backslashes when posting to BBoard

As far as I know, posting literal backslashes into the OpenACS BBoards is still a problem, due to Postgres interpreting them as escape characters. So FYI, here's the trivial little proc I run my code snippets through before posting them here
ad_proc dtk_openacs_bboard_quotehtml { string } {
   This takes a string (which is probably a code snippet) and converts
   it to something that will look right as HTML on the OpenACS bboard.
   It escapes any HTML in the string, and since backslashes currently
   get eaten up by Postgres, it <em>also</em> replaces all single
   backslashes with double backslashes.

   <p>
   Basically, if you want to post a code snippet on the
   <a href="https://openacs.org/bboard/">OpenACS BBoards</a>,
   run the code through this procedure, and then stick the result
   insite &lt;pre&gt; tags.

   @author Andrew Piskorski (atp@piskorski.com)
   @date 2002/04/09
} {
   set code_2 [ns_quotehtml $string]
   set n_regsubs [regsub -all -- {\} $code_2 {\\} code_2]
   return $code_2
}

Note that the regsub command above should show 2 and then 4 backslashes - we'll see if my little proc works for posting itself. :)