Is there any way to convert special characters in a string to named character entities? The string is obtained from a form field.

Thanks,

Jakob