Advertisements

convert_chars

Definition:
function convert_chars($content, $deprecated = '') {}

Converts a number of characters from a string.
Metadata tags title>> and category>> are removed, <br> and hr>> are converted into correct XHTML and Unicode characters are converted to the valid range.

Parameters

  • string $content: String of characters to be converted.
  • string $deprecated: Not used.

Return values

returns:Converted string.

Source code

function convert_chars($content, $deprecated = '') {

	if ( !empty( $deprecated ) )

		_deprecated_argument( __FUNCTION__, '0.71' );



	// Translation of invalid Unicode references range to valid range

	$wp_htmltranswinuni = array(

	'€' => '€', // the Euro sign

	'' => '',

	'‚' => '‚', // these are Windows CP1252 specific characters

	'ƒ' => 'ƒ',  // they would look weird on non-Windows browsers

	'„' => '„',

	'…' => '…',

	'†' => '†',

	'‡' => '‡',

	'ˆ' => 'ˆ',

	'‰' => '‰',

	'Š' => 'Š',

	'‹' => '‹',

	'Œ' => 'Œ',

	'' => '',

	'Ž' => 'ž',

	'' => '',

	'' => '',

	'‘' => '‘',

	'’' => '’',

	'“' => '“',

	'”' => '”',

	'•' => '•',

	'–' => '–',

	'—' => '—',

	'˜' => '˜',

	'™' => '™',

	'š' => 'š',

	'›' => '›',

	'œ' => 'œ',

	'' => '',

	'ž' => '',

	'Ÿ' => 'Ÿ'

	);



	// Remove metadata tags

	$content = preg_replace('/<title>(.+?)<\/title>/','',$content);

	$content = preg_replace('/<category>(.+?)<\/category>/','',$content);



	// Converts lone & characters into & (a.k.a. &amp;)

	$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);



	// Fix Word pasting

	$content = strtr($content, $wp_htmltranswinuni);



	// Just a little XHTML help

	$content = str_replace('<br>', '<br />', $content);

	$content = str_replace('<hr>', '<hr />', $content);



	return $content;

}

721

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: