public static function encode_dbname($st, $maxlength = 50): string
  {
    $st = self::remove_accents(self::cast($st));
    $res = '';

    if ( !\is_int($maxlength) ){
      $maxlength = mb_strlen($st);
    }

    for ( $i = 0; $i < $maxlength; $i++ ){
      if ( mb_ereg_match('[A-z0-9]',mb_substr($st,$i,1)) ){
        $res .= mb_substr($st,$i,1);
      }
      else if ( (mb_strlen($res) > 0) &&
        (mb_substr($res,-1) != '_') &&
        ($i < ( mb_strlen($st) - 1 )) ){
        $res .= '_';
      }
    }
    if ( substr($res, -1) === '_' ){
      $res = substr($res, 0, -1);
    }
    return $res;
  }