Advertisement
fruffl

Unicode Ranger

Apr 23rd, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. try
  2. {
  3.    
  4.     $value      = 'aBcDeFgHiJkLmNoPqRsTuVwXyZbarbäzföoßĐIJᾕ₱❶❷❸ㅳㅵㅸㅘㄸ㊁㚂㹂䜢';
  5.    
  6.     $string     = (new DataTypeString($value))->toUpper();
  7.     $charArray  = $string->toCharArray();
  8.     $range      = (new DataTypeCharArraySegment($charArray, 10, 10))->toLower();
  9.    
  10.     $iterator   = new Bits(DataTypeStringArray::IT_MODE_LO);
  11.     $reversed   = new DataTypeArray($range, $iterator);
  12.    
  13.     print "input\n";
  14.     print $value;
  15.     print "\n\n";
  16.     print "input->uppercase()\n";
  17.     print $string;
  18.     print "\n\n";
  19.     print "input->toCharArray()->range(10,10)->toLower()\n";
  20.     print "important: range is not a copy of charArray!\n";
  21.     foreach($charArray as $c) print $c; // prints barbäzföoßĐIJᾝ₱❶❷❸ㅳㅵㅸㅘㄸ㊁㚂㹂䜢
  22.     print "\n\n";
  23.     print "iterate range\n";
  24.     foreach($range as $c) print $c; // prints ĐIJᾕ₱❶❷❸ㅳㅵㅸ
  25.     print "\n\n";
  26.     print "iterate as FILO\n";
  27.     foreach($reversed as $c) print $c; // prints ㅸㅵㅳ❸❷❶₱ᾕIJĐ
  28.     print "\n\n";
  29.    
  30. }
  31. catch(\ILLI\Exception\Base $e)
  32. {
  33.     print $e->export()->asText();
  34. }
  35. catch(\Exception $e)
  36. {
  37.     var_dump($e);
  38. }
  39. /* result:
  40.  
  41.  
  42. input
  43. aBcDeFgHiJkLmNoPqRsTuVwXyZbarbäzföoßĐIJᾕ₱❶❷❸ㅳㅵㅸㅘㄸ㊁㚂㹂䜢
  44.  
  45. input->uppercase()
  46. ABCDEFGHIJKLMNOPQRSTUVWXYZBARBÄZFÖOßĐIJᾝ₱❶❷❸ㅳㅵㅸㅘㄸ㊁㚂㹂䜢
  47.  
  48. input->toCharArray()->range(10,10)->toLower()
  49. important: range is not a copy of charArray!
  50. ABCDEFGHIJklmnopqrstUVWXYZBARBÄZFÖOßĐIJᾝ₱❶❷❸ㅳㅵㅸㅘㄸ㊁㚂㹂䜢
  51.  
  52. iterate range
  53. klmnopqrst
  54.  
  55. iterate as FILO
  56. tsrqponmlk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement