PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/utf8/iconv_string_handler.php

http://viet-group.googlecode.com/
PHP | 125 lines | 46 code | 18 blank | 61 comment | 1 complexity | 9307ecff7a66da9ab3aba12a723115aa MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 22/8/2010, 19:33
  7. */
  8. if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );
  9. iconv_set_encoding( 'input_encoding', $global_config['site_charset'] );
  10. iconv_set_encoding( 'internal_encoding', $global_config['site_charset'] );
  11. iconv_set_encoding( 'output_encoding', $global_config['site_charset'] );
  12. /**
  13. * nv_internal_encoding()
  14. *
  15. * @param mixed $encoding
  16. * @return
  17. */
  18. function nv_internal_encoding ( $encoding )
  19. {
  20. return iconv_set_encoding( 'internal_encoding', $encoding );
  21. }
  22. /**
  23. * nv_strlen()
  24. *
  25. * @param mixed $string
  26. * @return
  27. */
  28. function nv_strlen( $string )
  29. {
  30. global $global_config;
  31. return iconv_strlen( $string, $global_config['site_charset'] );
  32. }
  33. /**
  34. * nv_substr()
  35. *
  36. * @param mixed $string
  37. * @param mixed $start
  38. * @param mixed $length
  39. * @return
  40. */
  41. function nv_substr( $string, $start, $length )
  42. {
  43. global $global_config;
  44. return iconv_substr( $string, $start, $length, $global_config['site_charset'] );
  45. }
  46. /**
  47. * nv_substr_count()
  48. *
  49. * @param mixed $haystack
  50. * @param mixed $needle
  51. * @return
  52. */
  53. function nv_substr_count( $haystack, $needle )
  54. {
  55. $needle = preg_quote( $needle, '/' );
  56. preg_match_all( '/' . $needle . '/u', $haystack, $dummy );
  57. return count( $dummy[0] );
  58. }
  59. /**
  60. * nv_strpos()
  61. *
  62. * @param mixed $haystack
  63. * @param mixed $needle
  64. * @param integer $offset
  65. * @return
  66. */
  67. function nv_strpos( $haystack, $needle, $offset = 0 )
  68. {
  69. global $global_config;
  70. return iconv_strpos( $haystack, $needle, $offset, $global_config['site_charset'] );
  71. }
  72. /**
  73. * nv_strrpos()
  74. *
  75. * @param mixed $haystack
  76. * @param mixed $needle
  77. * @param integer $offset
  78. * @return
  79. */
  80. function nv_strrpos( $haystack, $needle, $offset = 0 )
  81. {
  82. global $global_config;
  83. return iconv_strrpos( $haystack, $needle, $offset, $global_config['site_charset'] );
  84. }
  85. /**
  86. * nv_strtolower()
  87. *
  88. * @param mixed $string
  89. * @return
  90. */
  91. function nv_strtolower( $string )
  92. {
  93. include ( NV_ROOTDIR . '/includes/utf8/lookup.php' );
  94. return strtr( $string, $utf8_lookup['strtolower'] );
  95. }
  96. /**
  97. * nv_strtoupper()
  98. *
  99. * @param mixed $string
  100. * @return
  101. */
  102. function nv_strtoupper( $string )
  103. {
  104. include ( NV_ROOTDIR . '/includes/utf8/lookup.php' );
  105. return strtr( $string, $utf8_lookup['strtoupper'] );
  106. }
  107. ?>