Hoa central
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Hoa\Ustring\Ustring Class Reference
Inheritance diagram for Hoa\Ustring\Ustring:

Public Member Functions

 __construct ($string=null)
 
 append ($substring)
 
 prepend ($substring)
 
 pad ($length, $piece, $side=self::END)
 
 compare ($string)
 
 match ($pattern, &$matches=null, $flags=0, $offset=0, $global=false)
 
 replace ($pattern, $replacement, $limit=-1)
 
 split ($pattern, $limit=-1, $flags=self::WITHOUT_EMPTY)
 
 getIterator ()
 
 toLowerCase ()
 
 toUpperCase ()
 
 toAscii ($try=false)
 
 transliterate ($identifier, $start=0, $end=null)
 
 trim ($regex= '\s', $side=3)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 offsetExists ($offset)
 
 reduce ($start, $length=null)
 
 count ()
 
 getByteAt ($offset)
 
 getBytesLength ()
 
 getWidth ()
 
 getDirection ()
 
 copy ()
 
 __toString ()
 

Static Public Member Functions

static getCollator ()
 
static safePattern ($pattern)
 
static getTransliterator ($identifier)
 
static getCharDirection ($char)
 
static getCharWidth ($char)
 
static isCharPrintable ($char)
 
static fromCode ($code)
 
static toCode ($char)
 
static toBinaryCode ($char)
 
static transcode ($string, $from, $to= 'UTF-8')
 
static isUtf8 ($string)
 

Public Attributes

const LTR = 0
 
const RTL = 1
 
const BOM = 0xfeff
 
const LRM = 0x200e
 
const RLM = 0x200f
 
const LRE = 0x202a
 
const RLE = 0x202b
 
const PDF = 0x202c
 
const LRO = 0x202d
 
const RLO = 0x202e
 
const BEGINNING = 1
 
const END = 2
 
const WITHOUT_EMPTY = PREG_SPLIT_NO_EMPTY
 
const WITH_DELIMITERS = PREG_SPLIT_DELIM_CAPTURE
 
const WITH_OFFSET = 260
 
const GROUP_BY_PATTERN = PREG_PATTERN_ORDER
 
const GROUP_BY_TUPLE = PREG_SET_ORDER
 

Protected Member Functions

 computeOffset ($offset)
 

Protected Attributes

 $_string = null
 
 $_direction = null
 

Static Protected Attributes

static $_collator = null
 

Detailed Description

Class .

This class represents a UTF-8 string. Please, see: • http://www.ietf.org/rfc/rfc3454.txt;http://unicode.org/reports/tr9/;http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt.

Definition at line 53 of file Ustring.php.

Constructor & Destructor Documentation

Hoa\Ustring\Ustring::__construct (   $string = null)

Construct a UTF-8 string.

Parameters
string$stringString.
Returns
void

Definition at line 205 of file Ustring.php.

206  {
207  if (false === function_exists('mb_substr')) {
208  throw new Exception(
209  '%s needs the mbstring extension.',
210  0,
211  get_class($this)
212  );
213  }
214 
215  if (null !== $string) {
216  $this->append($string);
217  }
218 
219  return;
220  }
append($substring)
Definition: Ustring.php:228

Here is the call graph for this function:

Member Function Documentation

Hoa\Ustring\Ustring::__toString ( )

Transform the object as a string.

Returns
string

Definition at line 1028 of file Ustring.php.

1029  {
1030  return $this->_string;
1031  }
Hoa\Ustring\Ustring::append (   $substring)

Append a substring to the current string, i.e. add to the end.

Parameters
string$substringSubstring to append.
Returns

Definition at line 228 of file Ustring.php.

229  {
230  $this->_string .= $substring;
231 
232  return $this;
233  }

Here is the caller graph for this function:

Hoa\Ustring\Ustring::compare (   $string)

Make a comparison with a string. Return < 0 if current string is less than $string, > 0 if greater and 0 if equal.

Parameters
mixed$stringString.
Returns
int

Definition at line 287 of file Ustring.php.

288  {
289  if (null === $collator = static::getCollator()) {
290  return strcmp($this->_string, (string) $string);
291  }
292 
293  return $collator->compare($this->_string, $string);
294  }
Hoa\Ustring\Ustring::computeOffset (   $offset)
protected

Compute offset (negative, unbound etc.).

Parameters
int$offsetOffset.
Returns
int

Definition at line 603 of file Ustring.php.

604  {
605  $length = mb_strlen($this->_string);
606 
607  if (0 > $offset) {
608  $offset = -$offset % $length;
609 
610  if (0 !== $offset) {
611  $offset = $length - $offset;
612  }
613  } elseif ($offset >= $length) {
614  $offset %= $length;
615  }
616 
617  return $offset;
618  }

Here is the caller graph for this function:

Hoa\Ustring\Ustring::copy ( )

Copy current object string

Returns

Definition at line 1018 of file Ustring.php.

1019  {
1020  return clone $this;
1021  }
Hoa\Ustring\Ustring::count ( )

Count number of characters of the current string.

Returns
int

Definition at line 694 of file Ustring.php.

695  {
696  return mb_strlen($this->_string);
697  }

Here is the caller graph for this function:

static Hoa\Ustring\Ustring::fromCode (   $code)
static

Get a UTF-8 character from its decimal code representation.

Parameters
int$codeCode.
Returns
string

Definition at line 928 of file Ustring.php.

929  {
930  return mb_convert_encoding(
931  '&#x' . dechex($code) . ';',
932  'UTF-8',
933  'HTML-ENTITIES'
934  );
935  }

Here is the caller graph for this function:

Hoa\Ustring\Ustring::getByteAt (   $offset)

Get byte (not character) at a specific offset.

Parameters
int$offsetOffset (can be negative and unbound).
Returns
string

Definition at line 705 of file Ustring.php.

706  {
707  $length = strlen($this->_string);
708 
709  if (0 > $offset) {
710  $offset = -$offset % $length;
711 
712  if (0 !== $offset) {
713  $offset = $length - $offset;
714  }
715  } elseif ($offset >= $length) {
716  $offset %= $length;
717  }
718 
719  return $this->_string[$offset];
720  }
Hoa\Ustring\Ustring::getBytesLength ( )

Count number of bytes (not characters) of the current string.

Returns
int

Definition at line 727 of file Ustring.php.

728  {
729  return strlen($this->_string);
730  }
static Hoa\Ustring\Ustring::getCharDirection (   $char)
static

Get character of a specific character. Please, see the self::LTR and self::RTL constants.

Parameters
string$charCharacter.
Returns
int

Definition at line 773 of file Ustring.php.

774  {
775  $c = static::toCode($char);
776 
777  if (!(0x5be <= $c && 0x10b7f >= $c)) {
778  return static::LTR;
779  }
780 
781  if (0x85e >= $c) {
782  if (0x5be === $c ||
783  0x5c0 === $c ||
784  0x5c3 === $c ||
785  0x5c6 === $c ||
786  (0x5d0 <= $c && 0x5ea >= $c) ||
787  (0x5f0 <= $c && 0x5f4 >= $c) ||
788  0x608 === $c ||
789  0x60b === $c ||
790  0x60d === $c ||
791  0x61b === $c ||
792  (0x61e <= $c && 0x64a >= $c) ||
793  (0x66d <= $c && 0x66f >= $c) ||
794  (0x671 <= $c && 0x6d5 >= $c) ||
795  (0x6e5 <= $c && 0x6e6 >= $c) ||
796  (0x6ee <= $c && 0x6ef >= $c) ||
797  (0x6fa <= $c && 0x70d >= $c) ||
798  0x710 === $c ||
799  (0x712 <= $c && 0x72f >= $c) ||
800  (0x74d <= $c && 0x7a5 >= $c) ||
801  0x7b1 === $c ||
802  (0x7c0 <= $c && 0x7ea >= $c) ||
803  (0x7f4 <= $c && 0x7f5 >= $c) ||
804  0x7fa === $c ||
805  (0x800 <= $c && 0x815 >= $c) ||
806  0x81a === $c ||
807  0x824 === $c ||
808  0x828 === $c ||
809  (0x830 <= $c && 0x83e >= $c) ||
810  (0x840 <= $c && 0x858 >= $c) ||
811  0x85e === $c) {
812  return static::RTL;
813  }
814  } elseif (0x200f === $c) {
815  return static::RTL;
816  } elseif (0xfb1d <= $c) {
817  if (0xfb1d === $c ||
818  (0xfb1f <= $c && 0xfb28 >= $c) ||
819  (0xfb2a <= $c && 0xfb36 >= $c) ||
820  (0xfb38 <= $c && 0xfb3c >= $c) ||
821  0xfb3e === $c ||
822  (0xfb40 <= $c && 0xfb41 >= $c) ||
823  (0xfb43 <= $c && 0xfb44 >= $c) ||
824  (0xfb46 <= $c && 0xfbc1 >= $c) ||
825  (0xfbd3 <= $c && 0xfd3d >= $c) ||
826  (0xfd50 <= $c && 0xfd8f >= $c) ||
827  (0xfd92 <= $c && 0xfdc7 >= $c) ||
828  (0xfdf0 <= $c && 0xfdfc >= $c) ||
829  (0xfe70 <= $c && 0xfe74 >= $c) ||
830  (0xfe76 <= $c && 0xfefc >= $c) ||
831  (0x10800 <= $c && 0x10805 >= $c) ||
832  0x10808 === $c ||
833  (0x1080a <= $c && 0x10835 >= $c) ||
834  (0x10837 <= $c && 0x10838 >= $c) ||
835  0x1083c === $c ||
836  (0x1083f <= $c && 0x10855 >= $c) ||
837  (0x10857 <= $c && 0x1085f >= $c) ||
838  (0x10900 <= $c && 0x1091b >= $c) ||
839  (0x10920 <= $c && 0x10939 >= $c) ||
840  0x1093f === $c ||
841  0x10a00 === $c ||
842  (0x10a10 <= $c && 0x10a13 >= $c) ||
843  (0x10a15 <= $c && 0x10a17 >= $c) ||
844  (0x10a19 <= $c && 0x10a33 >= $c) ||
845  (0x10a40 <= $c && 0x10a47 >= $c) ||
846  (0x10a50 <= $c && 0x10a58 >= $c) ||
847  (0x10a60 <= $c && 0x10a7f >= $c) ||
848  (0x10b00 <= $c && 0x10b35 >= $c) ||
849  (0x10b40 <= $c && 0x10b55 >= $c) ||
850  (0x10b58 <= $c && 0x10b72 >= $c) ||
851  (0x10b78 <= $c && 0x10b7f >= $c)) {
852  return static::RTL;
853  }
854  }
855 
856  return static::LTR;
857  }
static Hoa\Ustring\Ustring::getCharWidth (   $char)
static

Get the number of column positions of a wide-character.

This is a PHP implementation of wcwidth() and wcswidth() (defined in IEEE Std 1002.1-2001) for Unicode, by Markus Kuhn. Please, see http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c.

The wcwidth(wc) function shall either return 0 (if wc is a null wide-character code), or return the number of column positions to be occupied by the wide-character code wc, or return -1 (if wc does not correspond to a printable wide-character code).

Parameters
string$charCharacter.
Returns
int

Definition at line 874 of file Ustring.php.

875  {
876  $char = (string) $char;
877  $c = static::toCode($char);
878 
879  // Test for 8-bit control characters.
880  if (0x0 === $c) {
881  return 0;
882  }
883 
884  if (0x20 > $c || (0x7f <= $c && $c < 0xa0)) {
885  return -1;
886  }
887 
888  // Non-spacing characters.
889  if (0xad !== $c &&
890  0 !== preg_match('#^[\p{Mn}\p{Me}\p{Cf}\x{1160}-\x{11ff}\x{200b}]#u', $char)) {
891  return 0;
892  }
893 
894  // If we arrive here, $c is not a combining C0/C1 control character.
895  return 1 +
896  (0x1100 <= $c &&
897  (0x115f >= $c || // Hangul Jamo init. consonants
898  0x2329 === $c || 0x232a === $c ||
899  (0x2e80 <= $c && 0xa4cf >= $c &&
900  0x303f !== $c) || // CJK…Yi
901  (0xac00 <= $c && 0xd7a3 >= $c) || // Hangul Syllables
902  (0xf900 <= $c && 0xfaff >= $c) || // CJK Compatibility Ideographs
903  (0xfe10 <= $c && 0xfe19 >= $c) || // Vertical forms
904  (0xfe30 <= $c && 0xfe6f >= $c) || // CJK Compatibility Forms
905  (0xff00 <= $c && 0xff60 >= $c) || // Fullwidth Forms
906  (0xffe0 <= $c && 0xffe6 >= $c) ||
907  (0x20000 <= $c && 0x2fffd >= $c) ||
908  (0x30000 <= $c && 0x3fffd >= $c)));
909  }
static Hoa\Ustring\Ustring::getCollator ( )
static

Get collator.

Returns

Definition at line 301 of file Ustring.php.

302  {
303  if (false === class_exists('Collator')) {
304  return null;
305  }
306 
307  if (null === static::$_collator) {
308  static::$_collator = new \Collator(setlocale(LC_COLLATE, null));
309  }
310 
311  return static::$_collator;
312  }
Hoa\Ustring\Ustring::getDirection ( )

Get direction of the current string. Please, see the self::LTR and self::RTL constants. It does not yet support embedding directions.

Returns
int

Definition at line 751 of file Ustring.php.

752  {
753  if (null === $this->_direction) {
754  if (null === $this->_string) {
755  $this->_direction = static::LTR;
756  } else {
757  $this->_direction = static::getCharDirection(
758  mb_substr($this->_string, 0, 1)
759  );
760  }
761  }
762 
763  return $this->_direction;
764  }
Hoa\Ustring\Ustring::getIterator ( )

Iterator over chars.

Returns

Definition at line 440 of file Ustring.php.

441  {
442  return new \ArrayIterator(preg_split('#(?<!^)(?!$)#u', $this->_string));
443  }
static Hoa\Ustring\Ustring::getTransliterator (   $identifier)
static

Get transliterator. See http://userguide.icu-project.org/transforms/general for $identifier.

Parameters
string$identifierIdentifier.
Returns

Definition at line 557 of file Ustring.php.

558  {
559  if (false === class_exists('Transliterator')) {
560  return null;
561  }
562 
563  return \Transliterator::create($identifier);
564  }
Hoa\Ustring\Ustring::getWidth ( )

Get the width of the current string. Useful when printing the string in monotype (some character need more than one column to be printed).

Returns
int

Definition at line 739 of file Ustring.php.

740  {
741  return mb_strwidth($this->_string);
742  }
static Hoa\Ustring\Ustring::isCharPrintable (   $char)
static

Check whether the character is printable or not.

Parameters
string$charCharacter.
Returns
bool

Definition at line 917 of file Ustring.php.

918  {
919  return 1 <= static::getCharWidth($char);
920  }
static Hoa\Ustring\Ustring::isUtf8 (   $string)
static

Check if a string is encoded in UTF-8.

Parameters
string$stringString.
Returns
bool

Definition at line 1008 of file Ustring.php.

1009  {
1010  return (bool) preg_match('##u', $string);
1011  }
Hoa\Ustring\Ustring::match (   $pattern,
$matches = null,
  $flags = 0,
  $offset = 0,
  $global = false 
)

Perform a regular expression (PCRE) match.

Parameters
string$patternPattern.
array$matchesMatches.
int$flagsPlease, see constants self::WITH_OFFSET, self::GROUP_BY_PATTERN and self::GROUP_BY_TUPLE.
int$offsetAlternate place from which to start the search.
bool$globalWhether the match is global or not.
Returns
int

Definition at line 348 of file Ustring.php.

354  {
355  $pattern = static::safePattern($pattern);
356 
357  if (0 === $flags) {
358  if (true === $global) {
359  $flags = static::GROUP_BY_PATTERN;
360  }
361  } else {
362  $flags &= ~PREG_SPLIT_OFFSET_CAPTURE;
363  }
364 
365 
366  $offset = strlen(mb_substr($this->_string, 0, $offset));
367 
368  if (true === $global) {
369  return preg_match_all(
370  $pattern,
371  $this->_string,
372  $matches,
373  $flags,
374  $offset
375  );
376  }
377 
378  return preg_match($pattern, $this->_string, $matches, $flags, $offset);
379  }
Hoa\Ustring\Ustring::offsetExists (   $offset)

Check if a specific offset exists.

Returns
bool

Definition at line 670 of file Ustring.php.

671  {
672  return true;
673  }
Hoa\Ustring\Ustring::offsetGet (   $offset)

Get a specific chars of the current string.

Parameters
int$offsetOffset (can be negative and unbound).
Returns
string

Definition at line 626 of file Ustring.php.

627  {
628  return mb_substr($this->_string, $this->computeOffset($offset), 1);
629  }
computeOffset($offset)
Definition: Ustring.php:603

Here is the call graph for this function:

Hoa\Ustring\Ustring::offsetSet (   $offset,
  $value 
)

Set a specific character of the current string.

Parameters
int$offsetOffset (can be negative and unbound).
string$valueValue.
Returns

Definition at line 638 of file Ustring.php.

639  {
640  $head = null;
641  $offset = $this->computeOffset($offset);
642 
643  if (0 < $offset) {
644  $head = mb_substr($this->_string, 0, $offset);
645  }
646 
647  $tail = mb_substr($this->_string, $offset + 1);
648  $this->_string = $head . $value . $tail;
649  $this->_direction = null;
650 
651  return $this;
652  }
computeOffset($offset)
Definition: Ustring.php:603

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Ustring\Ustring::offsetUnset (   $offset)

Delete a specific character of the current string.

Parameters
int$offsetOffset (can be negative and unbound).
Returns
string

Definition at line 660 of file Ustring.php.

661  {
662  return $this->offsetSet($offset, null);
663  }
offsetSet($offset, $value)
Definition: Ustring.php:638

Here is the call graph for this function:

Hoa\Ustring\Ustring::pad (   $length,
  $piece,
  $side = self::END 
)

Pad the current string to a certain length with another piece, aka piece.

Parameters
int$lengthLength.
string$piecePiece.
int$sideWhether we append at the end or the beginning of the current string.
Returns

Definition at line 257 of file Ustring.php.

258  {
259  $difference = $length - $this->count();
260 
261  if (0 >= $difference) {
262  return $this;
263  }
264 
265  $handle = null;
266 
267  for ($i = $difference / mb_strlen($piece) - 1; $i >= 0; --$i) {
268  $handle .= $piece;
269  }
270 
271  $handle .= mb_substr($piece, 0, $difference - mb_strlen($handle));
272 
273  return
274  static::END === $side
275  ? $this->append($handle)
276  : $this->prepend($handle);
277  }
append($substring)
Definition: Ustring.php:228
prepend($substring)
Definition: Ustring.php:241

Here is the call graph for this function:

Hoa\Ustring\Ustring::prepend (   $substring)

Prepend a substring to the current string, i.e. add to the start.

Parameters
string$substringSubstring to append.
Returns

Definition at line 241 of file Ustring.php.

242  {
243  $this->_string = $substring . $this->_string;
244 
245  return $this;
246  }

Here is the caller graph for this function:

Hoa\Ustring\Ustring::reduce (   $start,
  $length = null 
)

Reduce the strings.

Parameters
int$startPosition of first character.
int$lengthMaximum number of characters.
Returns

Definition at line 682 of file Ustring.php.

683  {
684  $this->_string = mb_substr($this->_string, $start, $length);
685 
686  return $this;
687  }
Hoa\Ustring\Ustring::replace (   $pattern,
  $replacement,
  $limit = -1 
)

Perform a regular expression (PCRE) search and replace.

Parameters
mixed$patternPattern(s).
mixed$replacementReplacement(s) (please, see preg_replace() documentation).
int$limitMaximum of replacements. -1 for unbound.
Returns

Definition at line 390 of file Ustring.php.

391  {
392  $pattern = static::safePattern($pattern);
393 
394  if (false === is_callable($replacement)) {
395  $this->_string = preg_replace(
396  $pattern,
397  $replacement,
398  $this->_string,
399  $limit
400  );
401  } else {
402  $this->_string = preg_replace_callback(
403  $pattern,
404  $replacement,
405  $this->_string,
406  $limit
407  );
408  }
409 
410  return $this;
411  }
static Hoa\Ustring\Ustring::safePattern (   $pattern)
static

Ensure that the pattern is safe for Unicode: add the “u” option.

Parameters
string$patternPattern.
Returns
string

Definition at line 320 of file Ustring.php.

321  {
322  $delimiter = mb_substr($pattern, 0, 1);
323  $options = mb_substr(
324  mb_strrchr($pattern, $delimiter, false),
325  mb_strlen($delimiter)
326  );
327 
328  if (false === strpos($options, 'u')) {
329  $pattern .= 'u';
330  }
331 
332  return $pattern;
333  }
Hoa\Ustring\Ustring::split (   $pattern,
  $limit = -1,
  $flags = self::WITHOUT_EMPTY 
)

Split the current string according to a given pattern (PCRE).

Parameters
string$patternPattern (as a regular expression).
int$limitMaximum of split. -1 for unbound.
int$flagsPlease, see constants self::WITHOUT_EMPTY, self::WITH_DELIMITERS, self::WITH_OFFSET.
Returns
array

Definition at line 422 of file Ustring.php.

426  {
427  return preg_split(
428  static::safePattern($pattern),
429  $this->_string,
430  $limit,
431  $flags
432  );
433  }
Hoa\Ustring\Ustring::toAscii (   $try = false)

Transform a UTF-8 string into an ASCII one. First, try with a transliterator. If not available, will fallback to a normalizer. If not available, will try something homemade.

Parameters
bool$tryTry something if is not present.
Returns
Exceptions

Definition at line 478 of file Ustring.php.

479  {
480  if (0 === preg_match('#[\x80-\xff]#', $this->_string)) {
481  return $this;
482  }
483 
484  $string = $this->_string;
485  $transId =
486  'Any-Latin; ' .
487  '[\p{S}] Name; ' .
488  'Latin-ASCII';
489 
490  if (null !== $transliterator = static::getTransliterator($transId)) {
491  $this->_string = preg_replace_callback(
492  '#\\\N\{([A-Z ]+)\}#u',
493  function (Array $matches) {
494  return '(' . strtolower($matches[1]) . ')';
495  },
496  $transliterator->transliterate($string)
497  );
498 
499  return $this;
500  }
501 
502  if (false === class_exists('Normalizer')) {
503  if (false === $try) {
504  throw new Exception(
505  '%s needs the class Normalizer to work properly, ' .
506  'or you can force a try by using %1$s(true).',
507  1,
508  __METHOD__
509  );
510  }
511 
512  $string = static::transcode($string, 'UTF-8', 'ASCII//IGNORE//TRANSLIT');
513  $this->_string = preg_replace('#(?:[\'"`^](\w))#u', '\1', $string);
514 
515  return $this;
516  }
517 
518  $string = \Normalizer::normalize($string, \Normalizer::NFKD);
519  $string = preg_replace('#\p{Mn}+#u', '', $string);
520  $this->_string = static::transcode($string, 'UTF-8', 'ASCII//IGNORE//TRANSLIT');
521 
522  return $this;
523  }
static Hoa\Ustring\Ustring::toBinaryCode (   $char)
static

Get a binary representation of a specific character.

Parameters
string$charCharacter.
Returns
string

Definition at line 977 of file Ustring.php.

978  {
979  $char = (string) $char;
980  $out = null;
981 
982  for ($i = 0, $max = strlen($char); $i < $max; ++$i) {
983  $out .= vsprintf('%08b', ord($char[$i]));
984  }
985 
986  return $out;
987  }
static Hoa\Ustring\Ustring::toCode (   $char)
static

Get a decimal code representation of a specific character.

Parameters
string$charCharacter.
Returns
int

Definition at line 943 of file Ustring.php.

944  {
945  $char = (string) $char;
946  $code = ord($char[0]);
947  $bytes = 1;
948 
949  if (!($code & 0x80)) {// 0xxxxxxx
950  return $code;
951  }
952 
953  if (($code & 0xe0) === 0xc0) { // 110xxxxx
954  $bytes = 2;
955  $code = $code & ~0xc0;
956  } elseif (($code & 0xf0) == 0xe0) { // 1110xxxx
957  $bytes = 3;
958  $code = $code & ~0xe0;
959  } elseif (($code & 0xf8) === 0xf0) { // 11110xxx
960  $bytes = 4;
961  $code = $code & ~0xf0;
962  }
963 
964  for ($i = 2; $i <= $bytes; $i++) {// 10xxxxxx
965  $code = ($code << 6) + (ord($char[$i - 1]) & ~0x80);
966  }
967 
968  return $code;
969  }

Here is the caller graph for this function:

Hoa\Ustring\Ustring::toLowerCase ( )

Perform a lowercase folding on the current string.

Returns

Definition at line 450 of file Ustring.php.

451  {
452  $this->_string = mb_strtolower($this->_string);
453 
454  return $this;
455  }
Hoa\Ustring\Ustring::toUpperCase ( )

Perform an uppercase folding on the current string.

Returns

Definition at line 462 of file Ustring.php.

463  {
464  $this->_string = mb_strtoupper($this->_string);
465 
466  return $this;
467  }
static Hoa\Ustring\Ustring::transcode (   $string,
  $from,
  $to = 'UTF-8' 
)
static

Transcode.

Parameters
string$stringString.
string$fromOriginal encoding.
string$toFinal encoding.
Returns
string

Definition at line 997 of file Ustring.php.

998  {
999  return iconv($from, $to, $string);
1000  }
Hoa\Ustring\Ustring::transliterate (   $identifier,
  $start = 0,
  $end = null 
)

Transliterate the string into another. See self::getTransliterator for more information.

Parameters
string$identifierIdentifier.
int$startStart.
int$endEnd.
Returns
Exceptions

Definition at line 535 of file Ustring.php.

536  {
537  if (null === $transliterator = static::getTransliterator($identifier)) {
538  throw new Exception(
539  '%s needs the class Transliterator to work properly.',
540  2,
541  __METHOD__
542  );
543  }
544 
545  $this->_string = $transliterator->transliterate($this->_string, $start, $end);
546 
547  return $this;
548  }
Hoa\Ustring\Ustring::trim (   $regex = '\s',
  $side = 3 
)

Strip characters (default ) of the current string.

Parameters
string$regexCharacters to remove.
int$sideWhether we trim the beginning, the end or both sides, of the current string.
Returns

Definition at line 574 of file Ustring.php.

575  {
576  $regex = '(?:' . $regex . ')+';
577  $handle = null;
578 
579  if (0 !== ($side & static::BEGINNING)) {
580  $handle .= '(^' . $regex . ')';
581  }
582 
583  if (0 !== ($side & static::END)) {
584  if (null !== $handle) {
585  $handle .= '|';
586  }
587 
588  $handle .= '(' . $regex . '$)';
589  }
590 
591  $this->_string = preg_replace('#' . $handle . '#u', '', $this->_string);
592  $this->_direction = null;
593 
594  return $this;
595  }

Member Data Documentation

Hoa\Ustring\Ustring::$_collator = null
staticprotected

Definition at line 195 of file Ustring.php.

Hoa\Ustring\Ustring::$_direction = null
protected

Definition at line 188 of file Ustring.php.

Hoa\Ustring\Ustring::$_string = null
protected

Definition at line 181 of file Ustring.php.

const Hoa\Ustring\Ustring::BEGINNING = 1

Represent the beginning of the string.

int

Definition at line 130 of file Ustring.php.

const Hoa\Ustring\Ustring::BOM = 0xfeff

ZERO WIDTH NON-BREAKING SPACE (ZWNPBSP, aka byte-order mark, BOM).

int

Definition at line 74 of file Ustring.php.

const Hoa\Ustring\Ustring::END = 2

Represent the end of the string.

int

Definition at line 137 of file Ustring.php.

const Hoa\Ustring\Ustring::GROUP_BY_PATTERN = PREG_PATTERN_ORDER

Group results by patterns.

int

Definition at line 167 of file Ustring.php.

const Hoa\Ustring\Ustring::GROUP_BY_TUPLE = PREG_SET_ORDER

Group results by tuple (set of patterns).

int

Definition at line 174 of file Ustring.php.

const Hoa\Ustring\Ustring::LRE = 0x202a

LEFT-TO-RIGHT EMBEDDING.

int

Definition at line 95 of file Ustring.php.

const Hoa\Ustring\Ustring::LRM = 0x200e

LEFT-TO-RIGHT MARK.

int

Definition at line 81 of file Ustring.php.

const Hoa\Ustring\Ustring::LRO = 0x202d

LEFT-TO-RIGHT OVERRIDE.

int

Definition at line 116 of file Ustring.php.

const Hoa\Ustring\Ustring::LTR = 0

Left-To-Right.

int

Definition at line 60 of file Ustring.php.

const Hoa\Ustring\Ustring::PDF = 0x202c

POP DIRECTIONAL FORMATTING.

int

Definition at line 109 of file Ustring.php.

const Hoa\Ustring\Ustring::RLE = 0x202b

RIGHT-TO-LEFT EMBEDDING.

int

Definition at line 102 of file Ustring.php.

const Hoa\Ustring\Ustring::RLM = 0x200f

RIGHT-TO-LEFT MARK.

int

Definition at line 88 of file Ustring.php.

const Hoa\Ustring\Ustring::RLO = 0x202e

RIGHT-TO-LEFT OVERRIDE.

int

Definition at line 123 of file Ustring.php.

const Hoa\Ustring\Ustring::RTL = 1

Right-To-Left.

int

Definition at line 67 of file Ustring.php.

const Hoa\Ustring\Ustring::WITH_DELIMITERS = PREG_SPLIT_DELIM_CAPTURE

Split: parenthesized expression in the delimiter pattern will be captured and returned.

int

Definition at line 152 of file Ustring.php.

const Hoa\Ustring\Ustring::WITH_OFFSET = 260

Split: offsets of captures will be returned.

int

Definition at line 159 of file Ustring.php.

const Hoa\Ustring\Ustring::WITHOUT_EMPTY = PREG_SPLIT_NO_EMPTY

Split: non-empty pieces is returned.

int

Definition at line 144 of file Ustring.php.


The documentation for this class was generated from the following file: