Hi Pros,
I have a question regarding handling chinese character.
I have an text area for user to key in sth. But when the user key in Chinese Character and click a button[this button is for the user to save what he/she key in the textarea into their local directory].
The problem is when i view the file just save, all display funny symbol although i have using utf8..
Can anyone tell me how to fix this problem i would sincerely appreciate?
Below is the php code
<?php
// Check for user data, if its not empty do this...
if ( strpos($topbarfilename5, ' ') !== FALSE ) {
print 'FOUND A SPACE!';
}
if ( !empty( $_POST['FileContent'] ) )
{
// stripslash the user input
$string = stripslashes( $_POST["FileContent"] );
// Create a unique-ish filename.
$FileName = "topbar".date("s.i").".php";
// $FileName = "topbar.php";
// Create and open the file.
fwrite ( $FileHandle, utf8_encode($string) );
// Write the data.
fwrite ( $FileHandle, $string );
// Close the file.
fclose ( $FileHandle );
// Set file header information.
header ( 'content="text/html; charset=utf-8' );
header ( 'Content-Description: File Transfer' );
header ( 'Content-Disposition: attachment; filename="' . basename( $FileName ) . '"' );
header ( 'Content-Length: ' . filesize( $FileName ) );
// Push file to client.
readfile( $FileName );
// Delete file.
unlink( $FileName );
exit();
}
?>