| | 332 | |
| | 333 | /** |
| | 334 | * Converts a number of characters from a string. |
| | 335 | * |
| | 336 | * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are |
| | 337 | * converted into correct XHTML and Unicode characters are converted to the |
| | 338 | * valid range. |
| | 339 | * |
| | 340 | * @param string $content String of characters to be converted. |
| | 341 | * |
| | 342 | * @return string Converted string. |
| | 343 | */ |
| | 344 | function bb_convert_chars( $content ) { |
| | 345 | // Translation of invalid Unicode references range to valid range |
| | 346 | $wp_htmltranswinuni = array( |
| | 347 | '€' => '€', // the Euro sign |
| | 348 | '' => '', |
| | 349 | '‚' => '‚', // these are Windows CP1252 specific characters |
| | 350 | 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers |
| | 351 | '„' => '„', |
| | 352 | '…' => '…', |
| | 353 | '†' => '†', |
| | 354 | '‡' => '‡', |
| | 355 | 'ˆ' => 'ˆ', |
| | 356 | '‰' => '‰', |
| | 357 | 'Š' => 'Š', |
| | 358 | '‹' => '‹', |
| | 359 | 'Œ' => 'Œ', |
| | 360 | '' => '', |
| | 361 | 'Ž' => 'ž', |
| | 362 | '' => '', |
| | 363 | '' => '', |
| | 364 | '‘' => '‘', |
| | 365 | '’' => '’', |
| | 366 | '“' => '“', |
| | 367 | '”' => '”', |
| | 368 | '•' => '•', |
| | 369 | '–' => '–', |
| | 370 | '—' => '—', |
| | 371 | '˜' => '˜', |
| | 372 | '™' => '™', |
| | 373 | 'š' => 'š', |
| | 374 | '›' => '›', |
| | 375 | 'œ' => 'œ', |
| | 376 | '' => '', |
| | 377 | 'ž' => '', |
| | 378 | 'Ÿ' => 'Ÿ' |
| | 379 | ); |
| | 380 | |
| | 381 | // Remove metadata tags |
| | 382 | $content = preg_replace( '/<title>(.+?)<\/title>/', '', $content ); |
| | 383 | $content = preg_replace( '/<category>(.+?)<\/category>/', '', $content ); |
| | 384 | |
| | 385 | // Converts lone & characters into & (a.k.a. &) |
| | 386 | $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); |
| | 387 | |
| | 388 | // Fix Word pasting |
| | 389 | $content = strtr( $content, $wp_htmltranswinuni ); |
| | 390 | |
| | 391 | // Just a little XHTML help |
| | 392 | $content = str_replace( '<br>', '<br />', $content ); |
| | 393 | $content = str_replace( '<hr>', '<hr />', $content ); |
| | 394 | |
| | 395 | return $content; |
| | 396 | } |
| | 397 | No newline at end of file |