You are here

function unicode_conversion_map in Typogrify 7

Same name and namespace in other branches
  1. 6 unicode-conversion.php \unicode_conversion_map()

Provides Unicode-mapping.

Parameters

string $type: The map type we're looking for, one of 'ligature', 'punctuation', 'arrow' 'nested' or 'all'.

Return value

array Array of conversions, keyed by the original string.

4 calls to unicode_conversion_map()
convert_characters in ./unicode-conversion.php
Perform character conversion.
_typogrify_filter_tips in ./typogrify.module
Filter tips callback for Typogrify filter.
_typogrify_process in ./typogrify.module
Processing function to apply the Typogrify filters.
_typogrify_settings in ./typogrify.module
Typogrify filter settings form.

File

./unicode-conversion.php, line 19
Return the unicode conversion maps.

Code

function unicode_conversion_map($type = 'all') {
  $map = array(
    // See http://www.unicode.org/charts/PDF/UFB00.pdf .
    'ligature' => array(
      'ffi' => 'ffi',
      'ffl' => 'ffl',
      'ff' => 'ff',
      'fi' => 'fi',
      'fl' => 'fl',
      'ij' => 'ij',
      'IJ' => 'IJ',
      'st' => 'st',
      'ss' => 'ß',
    ),
    // See http:#www.unicode.org/charts/PDF/U2000.pdf .
    'punctuation' => array(
      '...' => '…',
      '..' => '‥',
      '. . .' => '…',
      '---' => '—',
      '--' => '–',
    ),
    'fraction' => array(
      '1/4' => '¼',
      '1/2' => '½',
      '3/4' => '¾',
      '1/3' => '⅓',
      '2/3' => '⅔',
      '1/5' => '⅕',
      '2/5' => '⅖',
      '3/5' => '⅗',
      '4/5' => '⅘',
      '1/6' => '⅙',
      '5/6' => '⅚',
      '1/8' => '⅛',
      '3/8' => '⅜',
      '5/8' => '⅝',
      '7/8' => '⅞',
    ),
    'quotes' => array(
      ',,' => '„',
      '\'\'' => '”',
      '<<' => '«',
      '>>' => '»',
    ),
    // See http:#www.unicode.org/charts/PDF/U2190.pdf .
    'arrow' => array(
      '->>' => '↠',
      '<<-' => '↞',
      '->|' => '⇥',
      '|<-' => '⇤',
      '<->' => '↔',
      '->' => '→',
      '<-' => '←',
      '<=>' => '⇔',
      '=>' => '⇒',
      '<=' => '⇐',
    ),
  );
  if ($type == 'all') {
    return array_merge($map['ligature'], $map['arrow'], $map['punctuation'], $map['quotes'], $map['fraction']);
  }
  elseif ($type == 'nested') {
    return $map;
  }
  else {
    return $map[$type];
  }
}