You are here

function tweet_feed_filter_smart_quotes in Tweet Feed 8.3

Same name and namespace in other branches
  1. 7.3 tweet_feed.module \tweet_feed_filter_smart_quotes()
  2. 4.x tweet_feed.module \tweet_feed_filter_smart_quotes()

Filter smart quotes to ASCII equivalent.

Parameters

string $text: Input text to filter.

Return value

string $text Filtered text.

1 call to tweet_feed_filter_smart_quotes()
TweetEntity::setUserMentions in src/Entity/TweetEntity.php

File

./tweet_feed.module, line 199
Contains tweet_feed.module.

Code

function tweet_feed_filter_smart_quotes($text) {

  // Convert varieties of smart quotes to ACSII equivalent.
  $search = array(
    chr(0xe2) . chr(0x80) . chr(0x98),
    chr(0xe2) . chr(0x80) . chr(0x99),
    chr(0xe2) . chr(0x80) . chr(0x9c),
    chr(0xe2) . chr(0x80) . chr(0x9d),
    chr(0xe2) . chr(0x80) . chr(0x93),
    chr(0xe2) . chr(0x80) . chr(0x94),
  );
  $ascii_replace = array(
    "'",
    "'",
    '"',
    '"',
    '-',
    '—',
  );
  return str_replace($search, $ascii_replace, $text);
}