I tugging a post's content using database query and printing it. Regrettably, I'm losing all of the formatting that Wordpress puts in when outputting content. Like the additional br tags. Which function does Wordpress use to format the output? I must place the content using that function before printing it. Thank you ahead of time for the help.

If you possess the WordPress atmosphere loaded, you need to use

$formatted_content = apply_filters( 'the_content', $raw_content );

Which will apply every function Wordpress normally uses on the_content

Otherwise, take a look in the functions wptexturize, wpautop, yet others at http://core.trac.wordpress.org/browser/tags/3.0.4/wp-includes/formatting.php