modifiercompiler.from_charset.php 794 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty from_charset modifier plugin
  10. *
  11. * Type: modifier<br>
  12. * Name: from_charset<br>
  13. * Purpose: convert character encoding from $charset to internal encoding
  14. *
  15. * @author Rodney Rehm
  16. * @param array $params parameters
  17. * @return string with compiled code
  18. */
  19. function smarty_modifiercompiler_from_charset($params, $compiler)
  20. {
  21. if (!Smarty::$_MBSTRING) {
  22. // FIXME: (rodneyrehm) shouldn't this throw an error?
  23. return $params[0];
  24. }
  25. if (!isset($params[1])) {
  26. $params[1] = '"ISO-8859-1"';
  27. }
  28. return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
  29. }
  30. ?>