示例#1
0
 public function testNumBitsSet()
 {
     $bitfield = 1431655765;
     $this->assertTrue(CBitField::numBitsSet($bitfield) == 16);
     $bitfield = 1152419982;
     $this->assertTrue(CBitField::numBitsSet($bitfield) == 11);
 }
示例#2
0
 /**
  * @ignore
  */
 public static function collatorObject($caseInsensitive, $naturalOrder, $locale, $collationFlags)
 {
     // Is public to be accessible by other classes, such as CArray.
     assert('is_bool($caseInsensitive) && is_bool($naturalOrder) && is_cstring($locale) && ' . 'is_bitfield($collationFlags)', vs(isset($this), get_defined_vars()));
     assert('CULocale::isValid($locale) || CString::equalsCi($locale, "root")', vs(isset($this), get_defined_vars()));
     $coll = new Collator($locale);
     // Case sensitivity.
     if (!$caseInsensitive) {
         $coll->setStrength(Collator::TERTIARY);
     } else {
         $coll->setStrength(Collator::SECONDARY);
     }
     // Natural order.
     if (!$naturalOrder) {
         // To be sure.
         $coll->setAttribute(Collator::NUMERIC_COLLATION, Collator::OFF);
     } else {
         $coll->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
     }
     // Accents.
     if (CBitField::isBitSet($collationFlags, self::COLLATION_IGNORE_ACCENTS)) {
         $coll->setStrength(Collator::PRIMARY);
         if (!$caseInsensitive) {
             $coll->setAttribute(Collator::CASE_LEVEL, Collator::ON);
         }
     }
     // Invisible characters, some punctuation and symbols.
     if (CBitField::isBitSet($collationFlags, self::COLLATION_IGNORE_NONWORD)) {
         $coll->setAttribute(Collator::ALTERNATE_HANDLING, Collator::SHIFTED);
     }
     // Case order.
     if (!CBitField::isBitSet($collationFlags, self::COLLATION_UPPERCASE_FIRST)) {
         // To be sure.
         $coll->setAttribute(Collator::CASE_FIRST, Collator::OFF);
     } else {
         $coll->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
     }
     // "French" collation.
     if (CBitField::isBitSet($collationFlags, self::COLLATION_FRENCH)) {
         $coll->setAttribute(Collator::FRENCH_COLLATION, Collator::ON);
     }
     return $coll;
 }
示例#3
0
 protected static function filterFlagsFromOptions($options, &$filterFlags)
 {
     if (CBitField::isBitSet($options, self::DISALLOW_PRIVATE_RANGE)) {
         $filterFlags |= FILTER_FLAG_NO_PRIV_RANGE;
     }
     if (CBitField::isBitSet($options, self::DISALLOW_RESERVED_RANGE)) {
         $filterFlags |= FILTER_FLAG_NO_RES_RANGE;
     }
 }