PageRenderTime 71ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/phpmyadmin/libraries/string_mb.lib.php

http://github.com/jyr/MNPP
PHP | 77 lines | 18 code | 5 blank | 54 comment | 0 complexity | 5c1b91fb44ac0a310de5ee4baebdf3b2 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, LGPL-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, GPL-2.0, BSD-3-Clause, GPL-3.0, BSD-2-Clause
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Specialized String Functions for phpMyAdmin
  5. *
  6. * Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
  7. * http://www.orbis-terrarum.net/?l=people.robbat2
  8. *
  9. * Defines a set of function callbacks that have a pure C version available if
  10. * the "ctype" extension is available, but otherwise have PHP versions to use
  11. * (that are slower).
  12. *
  13. * The SQL Parser code relies heavily on these functions.
  14. *
  15. * @version $Id$
  16. * @package phpMyAdmin-String-MB
  17. */
  18. /**
  19. * Returns length of string depending on current charset.
  20. *
  21. * @uses mb_strlen()
  22. * @param string string to count
  23. * @return int string length
  24. * @access public
  25. * @author nijel
  26. * @todo rename to PM_STR_len()
  27. */
  28. function PMA_strlen($string)
  29. {
  30. return mb_strlen($string);
  31. }
  32. /**
  33. * Returns substring from string, works depending on current charset.
  34. *
  35. * @uses mb_substr()
  36. * @param string string to count
  37. * @param int start of substring
  38. * @param int length of substring
  39. * @return int substring
  40. * @access public
  41. * @author nijel
  42. * @todo rename to PM_STR_sub()
  43. */
  44. function PMA_substr($string, $start, $length = 2147483647)
  45. {
  46. return mb_substr($string, $start, $length);
  47. }
  48. /**
  49. * returns postion of $needle in $haystack or false if not found
  50. *
  51. * @uses mb_strpos()
  52. * @param string $needle
  53. * @param string $haystack
  54. * @return integer position of $needle in $haystack or false
  55. */
  56. function PMA_STR_pos($haystack, $needle, $offset = 0)
  57. {
  58. return mb_strpos($haystack, $needle, $offset);
  59. }
  60. /**
  61. * returns right most postion of $needle in $haystack or false if not found
  62. *
  63. * @uses mb_strrpos()
  64. * @param string $needle
  65. * @param string $haystack
  66. * @return integer position of $needle in $haystack or false
  67. */
  68. function PMA_STR_rPos($haystack, $needle, $offset = 0)
  69. {
  70. return mb_strrpos($haystack, $needle, $offset);
  71. }
  72. ?>