ent2ncr

Converts named entities into numbered entities.

Description

(string) ent2ncr( (string) $text ); 

Returns (string)

Text with converted entities.

Parameters (1)

0. $text (string)
The text within which entities will be converted.

Usage

  1. if ( !function_exists( 'ent2ncr' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The text within which entities will be converted. 
  5. $text = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ent2ncr($text); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function ent2ncr( $text ) { 
  2.  
  3. /** 
  4. * Filters text before named entities are converted into numbered entities. 
  5. * A non-null string must be returned for the filter to be evaluated. 
  6. * @since 3.3.0 
  7. * @param null $converted_text The text to be converted. Default null. 
  8. * @param string $text The text prior to entity conversion. 
  9. */ 
  10. $filtered = apply_filters( 'pre_ent2ncr', null, $text ); 
  11. if ( null !== $filtered ) 
  12. return $filtered; 
  13.  
  14. $to_ncr = array( 
  15. '"' => '"',  
  16. '&' => '&',  
  17. '<' => '<',  
  18. '>' => '>',  
  19. '|' => '|',  
  20. ' ' => ' ',  
  21. '¡' => '¡',  
  22. '¢' => '¢',  
  23. '£' => '£',  
  24. '¤' => '¤',  
  25. '¥' => '¥',  
  26. '¦' => '¦',  
  27. '&brkbar;' => '¦',  
  28. '§' => '§',  
  29. '¨' => '¨',  
  30. '¨' => '¨',  
  31. '©' => '©',  
  32. 'ª' => 'ª',  
  33. '«' => '«',  
  34. '¬' => '¬',  
  35. '­' => '­',  
  36. '®' => '®',  
  37. '¯' => '¯',  
  38. '&hibar;' => '¯',  
  39. '°' => '°',  
  40. '±' => '±',  
  41. '²' => '²',  
  42. '³' => '³',  
  43. '´' => '´',  
  44. 'µ' => 'µ',  
  45. '¶' => '¶',  
  46. '·' => '·',  
  47. '¸' => '¸',  
  48. '¹' => '¹',  
  49. 'º' => 'º',  
  50. '»' => '»',  
  51. '¼' => '¼',  
  52. '½' => '½',  
  53. '¾' => '¾',  
  54. '¿' => '¿',  
  55. 'À' => 'À',  
  56. 'Á' => 'Á',  
  57. 'Â' => 'Â',  
  58. 'Ã' => 'Ã',  
  59. 'Ä' => 'Ä',  
  60. 'Å' => 'Å',  
  61. 'Æ' => 'Æ',  
  62. 'Ç' => 'Ç',  
  63. 'È' => 'È',  
  64. 'É' => 'É',  
  65. 'Ê' => 'Ê',  
  66. 'Ë' => 'Ë',  
  67. 'Ì' => 'Ì',  
  68. 'Í' => 'Í',  
  69. 'Î' => 'Î',  
  70. 'Ï' => 'Ï',  
  71. 'Ð' => 'Ð',  
  72. 'Ñ' => 'Ñ',  
  73. 'Ò' => 'Ò',  
  74. 'Ó' => 'Ó',  
  75. 'Ô' => 'Ô',  
  76. 'Õ' => 'Õ',  
  77. 'Ö' => 'Ö',  
  78. '×' => '×',  
  79. 'Ø' => 'Ø',  
  80. 'Ù' => 'Ù',  
  81. 'Ú' => 'Ú',  
  82. 'Û' => 'Û',  
  83. 'Ü' => 'Ü',  
  84. 'Ý' => 'Ý',  
  85. 'Þ' => 'Þ',  
  86. 'ß' => 'ß',  
  87. 'à' => 'à',  
  88. 'á' => 'á',  
  89. 'â' => 'â',  
  90. 'ã' => 'ã',  
  91. 'ä' => 'ä',  
  92. 'å' => 'å',  
  93. 'æ' => 'æ',  
  94. 'ç' => 'ç',  
  95. 'è' => 'è',  
  96. 'é' => 'é',  
  97. 'ê' => 'ê',  
  98. 'ë' => 'ë',  
  99. 'ì' => 'ì',  
  100. 'í' => 'í',  
  101. 'î' => 'î',  
  102. 'ï' => 'ï',  
  103. 'ð' => 'ð',  
  104. 'ñ' => 'ñ',  
  105. 'ò' => 'ò',  
  106. 'ó' => 'ó',  
  107. 'ô' => 'ô',  
  108. 'õ' => 'õ',  
  109. 'ö' => 'ö',  
  110. '÷' => '÷',  
  111. 'ø' => 'ø',  
  112. 'ù' => 'ù',  
  113. 'ú' => 'ú',  
  114. 'û' => 'û',  
  115. 'ü' => 'ü',  
  116. 'ý' => 'ý',  
  117. 'þ' => 'þ',  
  118. 'ÿ' => 'ÿ',  
  119. 'Œ' => 'Œ',  
  120. 'œ' => 'œ',  
  121. 'Š' => 'Š',  
  122. 'š' => 'š',  
  123. 'Ÿ' => 'Ÿ',  
  124. 'ƒ' => 'ƒ',  
  125. 'ˆ' => 'ˆ',  
  126. '˜' => '˜',  
  127. 'Α' => 'Α',  
  128. 'Β' => 'Β',  
  129. 'Γ' => 'Γ',  
  130. 'Δ' => 'Δ',  
  131. 'Ε' => 'Ε',  
  132. 'Ζ' => 'Ζ',  
  133. 'Η' => 'Η',  
  134. 'Θ' => 'Θ',  
  135. 'Ι' => 'Ι',  
  136. 'Κ' => 'Κ',  
  137. 'Λ' => 'Λ',  
  138. 'Μ' => 'Μ',  
  139. 'Ν' => 'Ν',  
  140. 'Ξ' => 'Ξ',  
  141. 'Ο' => 'Ο',  
  142. 'Π' => 'Π',  
  143. 'Ρ' => 'Ρ',  
  144. 'Σ' => 'Σ',  
  145. 'Τ' => 'Τ',  
  146. 'Υ' => 'Υ',  
  147. 'Φ' => 'Φ',  
  148. 'Χ' => 'Χ',  
  149. 'Ψ' => 'Ψ',  
  150. 'Ω' => 'Ω',  
  151. 'α' => 'α',  
  152. 'β' => 'β',  
  153. 'γ' => 'γ',  
  154. 'δ' => 'δ',  
  155. 'ε' => 'ε',  
  156. 'ζ' => 'ζ',  
  157. 'η' => 'η',  
  158. 'θ' => 'θ',  
  159. 'ι' => 'ι',  
  160. 'κ' => 'κ',  
  161. 'λ' => 'λ',  
  162. 'μ' => 'μ',  
  163. 'ν' => 'ν',  
  164. 'ξ' => 'ξ',  
  165. 'ο' => 'ο',  
  166. 'π' => 'π',  
  167. 'ρ' => 'ρ',  
  168. 'ς' => 'ς',  
  169. 'σ' => 'σ',  
  170. 'τ' => 'τ',  
  171. 'υ' => 'υ',  
  172. 'φ' => 'φ',  
  173. 'χ' => 'χ',  
  174. 'ψ' => 'ψ',  
  175. 'ω' => 'ω',  
  176. 'ϑ' => 'ϑ',  
  177. 'ϒ' => 'ϒ',  
  178. 'ϖ' => 'ϖ',  
  179. ' ' => ' ',  
  180. ' ' => ' ',  
  181. ' ' => ' ',  
  182. '‌' => '‌',  
  183. '‍' => '‍',  
  184. '‎' => '‎',  
  185. '‏' => '‏',  
  186. '–' => '–',  
  187. '—' => '—',  
  188. '‘' => '‘',  
  189. '’' => '’',  
  190. '‚' => '‚',  
  191. '“' => '“',  
  192. '”' => '”',  
  193. '„' => '„',  
  194. '†' => '†',  
  195. '‡' => '‡',  
  196. '•' => '•',  
  197. '…' => '…',  
  198. '‰' => '‰',  
  199. '′' => '′',  
  200. '″' => '″',  
  201. '‹' => '‹',  
  202. '›' => '›',  
  203. '‾' => '‾',  
  204. '⁄' => '⁄',  
  205. '€' => '€',  
  206. 'ℑ' => 'ℑ',  
  207. '℘' => '℘',  
  208. 'ℜ' => 'ℜ',  
  209. '™' => '™',  
  210. 'ℵ' => 'ℵ',  
  211. '↵' => '↵',  
  212. '⇐' => '⇐',  
  213. '⇑' => '⇑',  
  214. '⇒' => '⇒',  
  215. '⇓' => '⇓',  
  216. '⇔' => '⇔',  
  217. '∀' => '∀',  
  218. '∂' => '∂',  
  219. '∃' => '∃',  
  220. '∅' => '∅',  
  221. '∇' => '∇',  
  222. '∈' => '∈',  
  223. '∉' => '∉',  
  224. '∋' => '∋',  
  225. '∏' => '∏',  
  226. '∑' => '∑',  
  227. '−' => '−',  
  228. '∗' => '∗',  
  229. '√' => '√',  
  230. '∝' => '∝',  
  231. '∞' => '∞',  
  232. '∠' => '∠',  
  233. '∧' => '∧',  
  234. '∨' => '∨',  
  235. '∩' => '∩',  
  236. '∪' => '∪',  
  237. '∫' => '∫',  
  238. '∴' => '∴',  
  239. '∼' => '∼',  
  240. '≅' => '≅',  
  241. '≈' => '≈',  
  242. '≠' => '≠',  
  243. '≡' => '≡',  
  244. '≤' => '≤',  
  245. '≥' => '≥',  
  246. '⊂' => '⊂',  
  247. '⊃' => '⊃',  
  248. '⊄' => '⊄',  
  249. '⊆' => '⊆',  
  250. '⊇' => '⊇',  
  251. '⊕' => '⊕',  
  252. '⊗' => '⊗',  
  253. '⊥' => '⊥',  
  254. '⋅' => '⋅',  
  255. '⌈' => '⌈',  
  256. '⌉' => '⌉',  
  257. '⌊' => '⌊',  
  258. '⌋' => '⌋',  
  259. '⟨' => '〈',  
  260. '⟩' => '〉',  
  261. '←' => '←',  
  262. '↑' => '↑',  
  263. '→' => '→',  
  264. '↓' => '↓',  
  265. '↔' => '↔',  
  266. '◊' => '◊',  
  267. '♠' => '♠',  
  268. '♣' => '♣',  
  269. '♥' => '♥',  
  270. '♦' => '♦' 
  271. ); 
  272.  
  273. return str_replace( array_keys($to_ncr), array_values($to_ncr), $text );