Transform a Stringset to a string in the binary mo format.
@param Stringset $set
@return string
491490
public static function toString(Stringset $set, $add_hash_table = true)
    {
        $set->sort();

        if ($add_hash_table) {
            $hash_table_size = self::nextPrime((int)(($set->size() * 4) / 3));
            if ($hash_table_size <= 2) {
                $hash_table_size = 3;
            }
        } else {
            $hash_table_size = 0;
        }

        $ostart = 7 * 4;
        $tstart = $ostart + ($set->size() * 8);
        $hstart = $tstart + ($set->size() * 8);

        $ovstart = $hstart + ($hash_table_size * (self::INT_SIZE / 8));

        $str = '';
        $str .= pack('LL', self::MAGIC_NUMBER, self::REVISION); // magic number and revision
        $str .= pack('L', $set->size()); // number of strings
        $str .= pack('L', $ostart); // start of original strings at 7 words
        $str .= pack('L', $tstart); // start of translated strings, 2 words per entry
        $str .= pack('L', $hash_table_size); // size of hashtable
        $str .= pack('L', $hstart); // start of hashtable

        $ids = '';
        $lengths = array();
        for ($i = 0; $i < $set->size(); $i += 1) {
            $item = $set->item($i);
            $id = $item['id'];
            if ($item['context'] !== null) {
                $id = $item['context'] . self::EOT . $id;
            }

            if ($item['plural'] !== null) {
                $id = $id . self::NUL . $item['plural'];
            }
            $str .= pack('LL', strlen($id), $ovstart + strlen($ids));
            $ids .= $id . self::NUL;
        }

        $tvstart = $ovstart + strlen($ids);

        $values = '';
        for ($i = 0; $i < $set->size(); $i += 1) {
            $item = $set->item($i);
            $value = implode(self::NUL, $item['strings']);
            $str .= pack('LL', strlen($value), $tvstart + strlen($values));
            $values .= $value . self::NUL;
        }

        if ($add_hash_table) {
            $hashtable = self::makeHashTable($set, $hash_table_size);
            foreach ($hashtable as $hash) {
                $str .= pack('L', $hash);
            }
        }
        $str .= $ids;
        $str .= $values;
        return $str;
    }
207744
public static void writeStringSet(DataOutputStream os, Collection<String> set) throws IOException {
		if(set==null) {
			os.writeInt(-1);
		} else {
			os.writeInt(set.size());
			for(String s : set) {
				writeString(os, s);
			}
		}

	}
83446
public static String serializeSet(Set<?> set) {
        if (set == null) {
            set = new HashSet<String>();
        }
        XStream xstream = new XStream(new DomDriver());
        return xstream.toXML(set);
    }
866405
static function strtolower( $text )
    {
        //We need to detect our internal charset
        if ( self::$charset === null )
        {
            self::$charset = eZTextCodec::internalCharset();
        }

        //First try to use mbstring
        if ( extension_loaded( 'mbstring' ) )
        {
            return mb_strtolower( $text, self::$charset );
        }
        else
        {
            // Fall back if mbstring is not available
            $char = eZCharTransform::instance();
            return $char->transformByGroup( $text, 'lowercase' );
        }
    }
1122102
public static String toHexString(final BitSet set) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(out);
        final long[] longs = set.toLongArray();
        for (long aLong : longs) {
            writer.write(Long.toHexString(aLong));
        }
        writer.flush();

        return new String(out.toByteArray(), java.nio.charset.StandardCharsets.UTF_8);
    }
1269871
public static function toFile(Stringset $set, $filename)
    {
        try {
            $str = self::toString($set, $options);
            if (!file_exists($filename) || is_writable($filename)) {
                file_put_contents($filename, $str);
            } else {
                throw new Exception("Cannot write to file");
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
1018379
public function getSet($set)
    {
        if (isset($this->sets[$set])) {
            return $this->sets[$set];
        }
        return null;
    }
272100
private function getNormalizedCharset($charset)
    {
        $upper = null;
        if (is_array($charset)) {
            $upper = array_map('strtoupper', $charset);
        } else {
            $upper = strtoupper($charset);
        }
        return preg_replace('/[^A-Z0-9]+/', '', $upper);
    }
1171455
private function generateGetSetBoolCallback( &$get, &$set, $columnName )
    {

        $this->class->classComponents[] = new FunctionDeclaration(
            "getset.{$columnName}.get",
            $this->generateGetCallbackForBool( $columnName )
        );

        $this->class->classComponents[] = new FunctionDeclaration(
            "getset.{$columnName}.set",
            $this->generateSetCallbackForBool( $columnName )
        );

    }
413044
private function databaseSetBuilder($set)
    {

        $s = '';
        $arr = [];

        foreach ($set as $key => $value) {
            $s .= "$key = ?,";
            $arr[] = $value;
        }

        return [

            'content' => rtrim($s, ","),
            'array' => $arr,
        ];
    }
262154
public static function fromASN1(Set $set): self
    {
        $attribs = array_map(
            function (UnspecifiedType $el) {
                return AttributeTypeAndValue::fromASN1($el->asSequence());
            }, $set->elements());
        return new self(...$attribs);
    }
962872
function generateString(set, length) {
    var content = '';

    // Cannot generate a string from an empty set
    if (set.length <= 0) {
      return content;
    }

    for (var i = 0; i < length; i++) {
      content += String.fromCharCode(
        set[Math.floor(Math.random() * set.length)]
      );
    }

    return content;
  }
1057344
static function Upper($text,$charset = null){
		static $TR_TABLES = array();

		$charset = self::_GetCharsetByName($charset);
		switch($charset){
			case "windows-1250":
			case "iso-8859-2":
				if(!isset($TR_TABLES[$charset])){
					require(dirname(__FILE__)."/tr_tables/lower_upper/$charset.php");
				}
				$text = strtr($text,$TR_TABLES[$charset]["mala"],$TR_TABLES[$charset]["velka"]);
				break;
			case "utf8":
				$text = mb_strtoupper($text,"utf8");
				break;
			case "ascii":
			default: 
				$text = strtoupper($text);
		}

		return $text;
	}
327634
public function union ($set) {
        if (is_array ($set)) {
            $parameters = $set;
        } else {
            $parameters = func_get_args ();
        }
        foreach ($parameters as $n => $set) {
            if ($set instanceof ARedisSet) {
                $parameters[$n] = $set->name;
            }
        }
        array_unshift ($parameters , $this->name);
        return call_user_func_array (array(
            $this->getConnection ()->getSlave(),
            "sunion"
        ) , $parameters);
    }
848606
public function union(Set $set): Set
    {
        $union = new self();

        foreach ($this as $value) {
            $union->add($value);
        }

        foreach ($set as $value) {
            $union->add($value);
        }

        return $union;
    }
1109537
public static function set_Inet( $inet )
    {
        if( $inet instanceof Inet ) {
            return $inet;
        }
        try {
            $inet = new Inet( $inet );
            return $inet;
        } catch ( \InvalidArgumentException $e ) {
            return null;
        }
    }
304292
public static function fromASN1(Set $set): Attributes
    {
        $attribs = array_map(
            function (UnspecifiedType $el) {
                return Attribute::fromASN1($el->asSequence());
            }, $set->elements());
        // cast attributes
        $attribs = array_map(
            function (Attribute $attr) {
                $oid = $attr->oid();
                if (array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
                    $cls = self::MAP_OID_TO_CLASS[$oid];
                    return $attr->castValues($cls);
                }
                return $attr;
            }, $attribs);
        return new self(...$attribs);
    }