Generate Alter Table Charset.

@param string $table
@param string $charset

@return string
5130
protected function getAlterTableCharset($table, $charset)
    {
        $table = $this->dba->ident($table);
        $charset = $this->dba->quote($charset);

        return sprintf("%s\$this->execute(\"ALTER TABLE %s CHARSET=%s;\");", $this->ind2, $table, $charset);
    }
594189
public function create($columns, $engine = 'MyISAM', $charset = 'utf8')
    {
        $schema = $comma = $isNull = $tableKey = $type = '';

        $schema .= strtoupper(__FUNCTION__).' TABLE IF NOT EXISTS
        `'.$this->database.'`.`'.$this->tableName.'` (';
        $arrCount = count($columns);
        $i = 0;

        foreach ($columns as $key => $value) {
            $increment = (isset($value['increment'])) ? 'AUTO_INCREMENT' : '';
            if (isset($value['key'])) {
                $tableKey = strtoupper($value['key']).' ';

                if ($value['key'] == 'primary') {
                    $tableKey = 'PRIMARY KEY';
                }
            } else {
                $tableKey = '';
            }

            $isNull = (isset($value['null']) &&
                $value['null'] == true
            ) ? ' DEFAULT NULL' : ' NOT NULL';

            switch (strtolower($value['type'])) {

                case 'int':
                    $len = (isset($value['length'])) ? $value['length'] : 11;
                    list($type, $length) = $this->columnType($value['type'], $len);
                    break;
                case 'char':
                    list($type, $length) = $this->columnType($value['type'], $value['length'], 2);
                    break;
                case 'string':
                    list($type, $length) = $this->columnType('varchar', $value['length'], 200);
                    break;
                case 'text':
                    $type = 'TEXT';
                    break;
                case 'longtext':
                    $type = $value['type'];
                    break;
                case 'float':
                    list($type, $length) = $this->columnType($value['type'], $value['length'], '10,2');
                    break;
                case 'decimal':
                    list($type, $length) = $this->columnType($value['type'], $value['length'], '10,2');
                    break;
                case 'enum':
                    $length = implode('","', $value['length']);
                    $type = strtoupper($value['type']).'("'.$length.'")'.(isset($value['default']) ?  " DEFAULT '".$value['default']."'" : '');
                    break;
                case 'date':
                    $type = 'date';
                    break;
                case 'datetime':
                    $len = (isset($value['length'])) ? $value['length'] : "NOT NULL DEFAULT '0000:00:00 00:00:00'";
                    $type = strtoupper($value['type']).' '.$len;
                    $isNull = '';
                    break;
                case 'time':
                    $type = 'time';
                    break;
                case 'timestamp':
                    $len = (isset($value['length'])) ? $value['length'] : '';
                    $type = strtoupper($value['type']).' '.$len;
                    break;
            }

            $comma = ($i < $arrCount - 1) ? ',' : '';

            $schema .= '`'.$value['column'].'` '.strtoupper($type).' '
                .$increment.' '.$tableKey.PHP_EOL.$isNull.PHP_EOL;
            $schema .= $comma;

            $i++;
        }

        $schema .= ') ENGINE='.$engine.' DEFAULT  CHARSET='.$charset.';'.PHP_EOL;

        $this->schema = $schema;

        return $this;
    }
1088460
private function _getCharset($charset=null)
    {
        if (! $charset) {
            return;
        }

        $expr   = '/^(charset=)(\w+)$/';
        $tokens = array_filter(
            $charset, function ($token) use ($expr) {
                return preg_match($expr, $token, $matches);
            }
        );
        if (count($tokens) > 0) {
            preg_match($expr, array_shift($tokens), $matches);
            $_charset = $matches[2];
        } else {
            $_charset = null;
        }

        return $_charset;
    }
668810
public function setCharset($charset)
    {
        if ('UTF8' === $charset = strtoupper($charset)) {
            $charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
        }
        $this->charset = $charset;

        foreach ($this->helpers as $helper) {
            $helper->setCharset($this->charset);
        }
    }
777450
public function getCharacterSet($table, $field = null)
	{
		$create = $this->getTableCreate($table);

		if (isset($field))
		{
			preg_match('/' . $this->quoteName($field) . ' [[:alnum:]\(\)]* CHARACTER SET ([[:alnum:]]*)/', $create[$table], $matches);
		}
		else
		{
			preg_match('/CHARSET=([[:alnum:]]*)/', $create[$table], $matches);
		}

		return (isset($matches[1])) ? $matches[1] : false;
	}
528338
public function generateTableTca($table, $tca)
    {

        $tcaTemplate = array(
            'ctrl' => array(
                'title' => 'IRRE-Table',
                'label' => 'uid',
                'tstamp' => 'tstamp',
                'crdate' => 'crdate',
                'cruser_id' => 'cruser_id',
                'dividers2tabs' => true,
                'versioningWS' => true,
                'languageField' => 'sys_language_uid',
                'transOrigPointerField' => 'l10n_parent',
                'transOrigDiffSourceField' => 'l10n_diffsource',
                'delete' => 'deleted',
                'enablecolumns' => array(
                    'disabled' => 'hidden',
                    'starttime' => 'starttime',
                    'endtime' => 'endtime',
                ),
                'searchFields' => '',
                'dynamicConfigFile' => '',
                'iconfile' => ''
            ),
            'interface' => array(
                'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, ',
            ),
            'types' => array(
                '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime'),
            ),
            'palettes' => array(
                '1' => array('showitem' => ''),
            ),
            'columns' => array(
                'sys_language_uid' => array(
                    'exclude' => 1,
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
                    'config' => array(
                        'type' => 'select',
                        'renderType' => 'selectSingle',
                        'items' => array(
                            array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1, 'flags-multiple'),
                        ),
                        'special' => 'languages',
                        'default' => 0
                    ),
                ),
                'l10n_parent' => array(
                    'displayCond' => 'FIELD:sys_language_uid:>:0',
                    'exclude' => 1,
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
                    'config' => array(
                        'type' => 'select',
                        'renderType' => 'selectSingle',
                        'items' => array(
                            array('', 0),
                        ),
                        'foreign_table' => 'tx_test_domain_model_murph',
                        'foreign_table_where' => 'AND tx_test_domain_model_murph.pid=###CURRENT_PID### AND tx_test_domain_model_murph.sys_language_uid IN (-1,0)',
                        'default' => 0,
                    ),
                ),
                'l10n_diffsource' => array(
                    'config' => array(
                        'type' => 'passthrough',
                    ),
                ),
                't3ver_label' => array(
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel',
                    'config' => array(
                        'type' => 'input',
                        'size' => 30,
                        'max' => 255,
                    )
                ),
                'hidden' => array(
                    'exclude' => 1,
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden',
                    'config' => array(
                        'type' => 'check',
                    ),
                ),
                'starttime' => array(
                    'exclude' => 1,
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
                    'config' => array(
                        'behaviour' => array(
                            'allowLanguageSynchronization' => true
                        ),
                        'renderType' => 'inputDateTime',
                        'type' => 'input',
                        'size' => 13,
                        'eval' => 'datetime,int',
                        'checkbox' => 0,
                        'default' => 0
                    ),
                ),
                'endtime' => array(
                    'exclude' => 1,
                    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime',
                    'config' => array(
                        'behaviour' => array(
                            'allowLanguageSynchronization' => true
                        ),
                        'renderType' => 'inputDateTime',
                        'type' => 'input',
                        'size' => 13,
                        'eval' => 'datetime,int',
                        'checkbox' => 0,
                        'default' => 0
                    ),
                ),
                'parentid' => array(
                    'config' => array(
                        'type' => 'select',
                        'renderType' => 'selectSingle',
                        'items' => array(
                            array('', 0),
                        ),
                        'foreign_table' => 'tt_content',
                        'foreign_table_where' =>
                            'AND tt_content.pid=###CURRENT_PID###
								AND tt_content.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)',
                    ),
                ),
                'parenttable' => array(
                    'config' => array(
                        'type' => 'passthrough',
                    ),
                ),
                'sorting' => array(
                    'config' => array(
                        'type' => 'passthrough',
                    ),
                ),
            ),
        );

        $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
        $generalUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Utility\\GeneralUtility');

        // now add all the fields that should be shown
        $prependTabs = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, ";
        if ($tca) {
            $i = 0;
            uasort($tca, function ($columnA, $columnB) {
                $a = isset($columnA['order']) ? (int)$columnA['order'] : 0;
                $b = isset($columnB['order']) ? (int)$columnB['order'] : 0;
                return $a - $b;
            });

            foreach ($tca as $fieldKey => $configuration) {
                // check if this field is of type tab
                $formType = $fieldHelper->getFormType($fieldKey, "", $table);
                if ($formType == "Tab") {
                    $label = $configuration["label"];
                    // if a tab is in the first position then change the name of the general tab
                    if ($i === 0) {
                        $prependTabs = '--div--;' . $label . "," . $prependTabs;
                    } else {
                        // otherwise just add new tab
                        $fields[] = '--div--;' . $label;
                    }
                } else {
                    $fields[] = $fieldKey;
                }
                $i++;
            }
        }

        // take first field for inline label
        if (!empty($fields)) {
            $labelField = $generalUtility->getFirstNoneTabField($fields);
        }

        // get parent table of this inline table
        $parentTable = $fieldHelper->getFieldType($table);

        // Adjust TCA-Template
        $tableTca = $tcaTemplate;

        $tableTca["ctrl"]["title"] = $table;
        $tableTca["ctrl"]["label"] = $labelField;
        $tableTca["ctrl"]["searchFields"] = implode(",", (array)$fields);
        $tableTca["interface"]["showRecordFieldList"] = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, " . implode(", ",
                (array)$fields);
        $tableTca["types"]["1"]["showitem"] = $prependTabs . implode(", ",
                (array)$fields) . ", --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime";

        $tableTca["columns"]["l10n_parent"]["config"]["foreign_table"] = $table;
        $tableTca["columns"]["l10n_parent"]["config"]["foreign_table_where"] = 'AND ' . $table . '.pid=###CURRENT_PID### AND ' . $table . '.sys_language_uid IN (-1,0)';

        $tableTca["columns"]["parentid"]["config"]["foreign_table"] = $parentTable;
        $tableTca["columns"]["parentid"]["config"]["foreign_table_where"] = 'AND ' . $parentTable . '.pid=###CURRENT_PID### AND ' . $parentTable . '.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)';

        // Add some stuff we need to make irre work like it should
        $GLOBALS["TCA"][$table] = $tableTca;
    }
255105
public function setCharset($charset)
    {
        $this->charset = $charset;
        if (!$this->headerCharset) {
            $this->headerCharset = $charset;
        }

        return $this;
    }
295288
protected function getPhinxTableEncoding($attributes, $table)
    {
        if (!empty($table['table']['character_set_name'])) {
            $attributes[] = '\'encoding\' => "' . addslashes($table['table']['character_set_name']) . '"';
        } else {
            $attributes[] = '\'encoding\' => "utf8"';
        }

        return $attributes;
    }
567133
public function generateTableOptions(Table $table)
    {
        $code = [];
        $options = $table->getOptions();
        
        $code = $this->valuetize($options);
        return $code === '[]' ? '' : ', ' . $code;
    }
1187330
public function setText($content, $charset = 'utf-8') {
        $this->text = $content;
        $this->textCharset = $charset;
        return $this;
    }
1123418
static function Lower($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]["velka"],$TR_TABLES[$charset]["mala"]);
				break;
			case "utf8":
				$text = mb_strtolower($text,"utf8");
				break;
			default: 
				$text = strtolower($text);
		}

		return $text;
	}
738631
public function setCharset($charset)
    {
        if (is_string($charset)) {
            if (in_array($charset, mb_list_encodings())) {
                $this->charset = $charset;
            } else {
                throw new \InvalidArgumentException(
                    "Invalid value '" . $charset . "' for argument 'charset' given. Charset not supported."
                );
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($charset). "' for argument 'charset' given."
            );
        }

        return $this;
    }
713290
public function setCharset($charset, $method = null)
    {
        if ($method === null) {
            $method = $this->getConfig('method');
        }

        $this->query($method . ' ' . $charset);

        return $this->getConnect()->set_charset($charset);
    }
1322163
public function quoteTable($table): string
	{
		$table = $this->prefixTable($table);

		// Finally, quote the table
		return $this->quoteIdent($table);
	}
433266
public function createTable(Table $table)
    {
        if (!$table->hasOption('charset') && !$table->hasOption('collate')) {
            $connParams = $this->_conn->getParams();
            if (isset($connParams['defaultTableOptions']['charset']) && isset($connParams['defaultTableOptions']['collate'])) {
                $table
                    ->addOption('charset', $connParams['defaultTableOptions']['charset'])
                    ->addOption('collate', $connParams['defaultTableOptions']['collate'])
                ;
            }
        }

        return parent::createTable($table);
    }
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;
	}
629351
protected function check($table) {
		if ($this->quoteCharacter && strpos($table, $this->quoteCharacter)!==false) {
		  throw new Redbean_Exception_Security('Illegal chars in table name');
	    }
		return $table;
	}