You can use
Cheers,
Matthew
STSHtmlEncode
. It's a global function that is a part of SP. You should probably roll your own, so this wont create a problem for you when/if that function is removed.Cheers,
Matthew