Try htmlentities():
htmlentities("'", ENT_QUOTES, 'UTF-8', true);
Regarding your second question, yes (as a general rule).
To output user input / raw input you should always use htmlspecialchars() at least.
Alix Axel
2010-01-22 17:03:06