Form Help : Handle Chinese Character

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qiqinuinaifen128
    New Member
    • Dec 2007
    • 10

    #1

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

    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(); 
    } 
    
    ?>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Have a look at utf8_encode().

    - Mark.

    Comment

    • qiqinuinaifen128
      New Member
      • Dec 2007
      • 10

      #3
      i change my script to this, but how come it show me another type of funny symbol?
      fwrite ( $FileHandle, utf8_encode($st ring) );

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Try changing the content type header to: Content-Type: text/html;charset=ut f-8

        Comment

        • qiqinuinaifen128
          New Member
          • Dec 2007
          • 10

          #5
          my initial is content="text/html; charset=utf-8"
          is it the same?

          Comment

          • qiqinuinaifen128
            New Member
            • Dec 2007
            • 10

            #6
            I just try. It's the same.

            Comment

            Working...