BP_Attachment::sanitize_utf8_filename( string $retval )
Helper to convert utf-8 characters in filenames to their ASCII equivalent.
Description
Parameters
- $retval
-
(Required) Filename.
Return
(string)
Source
File: bp-core/classes/class-bp-attachment.php
public function sanitize_utf8_filename( $retval ) { // PHP 5.4+ or with PECL intl 2.0+ if ( function_exists( 'transliterator_transliterate' ) && seems_utf8( $retval ) ) { $retval = transliterator_transliterate( 'Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove', $retval ); // Older. } else { // Use WP's built-in function to convert accents to their ASCII equivalent. $retval = remove_accents( $retval ); // Still here? use iconv(). if ( function_exists( 'iconv' ) && seems_utf8( $retval ) ) { $retval = iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $retval ); } } return $retval; }
Changelog
Version | Description |
---|---|
BuddyPress 2.9.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.