Making WordPress.org

Changeset 3182


Ignore:
Timestamp:
05/19/2016 07:03:38 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Handle UTF-16 files.

See #1724

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-readme-parser.php

    r3181 r3182  
    6565        $contents = array_map( array( $this, 'strip_newlines' ), $contents );
    6666
    67         // Strip BOM
     67        // Strip UTF8 BOM if present
    6868        if ( strpos( $contents[0], "\xEF\xBB\xBF" ) === 0 ) {
    6969            $contents[0] = substr( $contents[0], 3 );
     70        }
     71
     72        // Convert UTF-16 files
     73        if ( strpos( $contents[0], "\xFF\xFE" ) === 0 ) {
     74            foreach ( $contents as $i => $line ) {
     75                $contents[$i] = mb_convert_encoding( $line, 'UTF-8', 'UTF-16' );
     76            }
    7077        }
    7178
Note: See TracChangeset for help on using the changeset viewer.