wpseek.com
A WordPress-centric search engine for devs and theme authors
_wp_json_convert_string is private and should not be used in themes or plugins directly.
_wp_json_convert_string › WordPress Function
Since4.1.0
Deprecatedn/a
› _wp_json_convert_string ( $string )
Access: |
|
Parameters: |
|
See: | |
Returns: |
|
Defined at: |
|
Codex: |
Convert a string to UTF-8, so that it can be safely encoded to JSON.
Related Functions: _wp_iso_convert, wp_timezone_string, wp_user_settings, wp_convert_widget_settings, wp_json_encode
Source
function _wp_json_convert_string( $string ) { static $use_mb = null; if ( is_null( $use_mb ) ) { $use_mb = function_exists( 'mb_convert_encoding' ); } if ( $use_mb ) { $encoding = mb_detect_encoding( $string, mb_detect_order(), true ); if ( $encoding ) { return mb_convert_encoding( $string, 'UTF-8', $encoding ); } else { return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' ); } } else { return wp_check_invalid_utf8( $string, true ); } }