Listed on

Internationalising PHP Web Control Panels

Cocoa on OS X is Unicode based. This makes working with non-ASCII character sets fairly easy … provided you can encode them in a unicode format. PHP has some facilities for writing UTF-8 character set based files.
A naive Googling would lead you to believe that the php function utf8_encode() would be all would you need. Unfortunately it really only does part of the job. Reading the documentation you discover that the function actually handles iso-8859-1 characters well. To handle languages like Turkish and Russian the function html_entity_decode() covers the other non-english characters.

Using

$output_string = html_entity_decode(stripslashes($_REQUEST[text], ENT_QUOTES, "utf-8”))

Takes the value of an HTML textarea named text and converts it to a UTF-8 string which you can write directly to a file for display.