Results 1 to 2 of 2

Thread: Form Help : Handle Chinese Character

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    139

    Form Help : Handle Chinese Character

    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..

    Can anyone tell me how to fix this problem i would sincerely appreciate?

    Below is the php code i am using for the save button. I wonder if i want to fix this problem. how to start, is it because of my php script or html code....
    I heard from people that using utf8_encode(string), how to add it in to my script?

    Code:
    # <?php 
    # // Check for user data, if its not empty do this... 
    # if ( !empty( $_POST['FileContent'] ) ) 
    # { 
    #         // stripslash the user input 
    #         $string = stripslashes( $_POST["FileContent"] ); 
    #         // Create a unique-ish filename. 
    #         $FileName = "Sitemaps.php"; 
    #         // Create and open the file. 
    #         $FileHandle = fopen ( $FileName, 'w' ); 
    #         // Write the data. 
    #         fwrite ( $FileHandle, $string ); 
    #         // Close the file. 
    #         fclose ( $FileHandle ); 
    #         // Set file header information. 
    #         header ( 'Content-Type: text/html' ); 
    #         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(); 
    # } 
    #  
    # ?>

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Form Help : Handle Chinese Character

    before I get into anything -- I don't know if you added them yourself, but those hash signs (#) are comments in PHP. for this script to run at all, you would need to remove them. now, to use utf8_encode(), you simply apply it to your POST variable before you save the file contents.
    PHP Code:
    $encoded_string utf8_encode($_POST['FileContent']); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width