Misc.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Miscellaneous utility values and functions for OpenID and Yadis.
  4. *
  5. * @package OpenID
  6. * @author JanRain, Inc. <openid@janrain.com>
  7. * @copyright 2005-2008 Janrain, Inc.
  8. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache
  9. */
  10. function Auth_Yadis_getUCSChars()
  11. {
  12. return array(
  13. array(0xA0, 0xD7FF),
  14. array(0xF900, 0xFDCF),
  15. array(0xFDF0, 0xFFEF),
  16. array(0x10000, 0x1FFFD),
  17. array(0x20000, 0x2FFFD),
  18. array(0x30000, 0x3FFFD),
  19. array(0x40000, 0x4FFFD),
  20. array(0x50000, 0x5FFFD),
  21. array(0x60000, 0x6FFFD),
  22. array(0x70000, 0x7FFFD),
  23. array(0x80000, 0x8FFFD),
  24. array(0x90000, 0x9FFFD),
  25. array(0xA0000, 0xAFFFD),
  26. array(0xB0000, 0xBFFFD),
  27. array(0xC0000, 0xCFFFD),
  28. array(0xD0000, 0xDFFFD),
  29. array(0xE1000, 0xEFFFD)
  30. );
  31. }
  32. function Auth_Yadis_getIPrivateChars()
  33. {
  34. return array(
  35. array(0xE000, 0xF8FF),
  36. array(0xF0000, 0xFFFFD),
  37. array(0x100000, 0x10FFFD)
  38. );
  39. }
  40. function Auth_Yadis_pct_escape_unicode($char_match)
  41. {
  42. $c = $char_match[0];
  43. $result = "";
  44. for ($i = 0; $i < strlen($c); $i++) {
  45. $result .= "%".sprintf("%X", ord($c[$i]));
  46. }
  47. return $result;
  48. }
  49. function Auth_Yadis_startswith($s, $stuff)
  50. {
  51. return strpos($s, $stuff) === 0;
  52. }