Exemplo n.º 1
0
 public static function getSjisAliases()
 {
     $aliases = mb_encoding_aliases('SJIS');
     if ($mimeName = mb_preferred_mime_name('SJIS')) {
         $aliases[] = $mimeName;
     }
     return $aliases;
 }
Exemplo n.º 2
0
function mb_http_output($encoding = '')
{
    global $mbemu_internals;
    if ($encoding == '') {
        return $mbemu_internals['ini_file']['http_output'];
    }
    if (strtolower($encoding) == 'pass') {
        $mbemu_internals['ini_file']['http_output'] = 'pass';
        return TRUE;
    }
    $mbemu_internals['ini_file']['http_output'] = mb_preferred_mime_name($encoding);
    return TRUE;
}
Exemplo n.º 3
0
function mb_encode_mimeheader($str, $encoding = "ISO-2022-JP", $transfer_encoding = "B", $linefeed = "\r\n")
{
    global $_mb_encoding;
    if ($transfer_encoding == "b") {
        $transfer_encoding = "B";
    }
    if ($transfer_encoding != "B") {
        $transfer_encoding = "Q";
    }
    $encoding = strtoupper($encoding);
    $head = '=?' . mb_preferred_mime_name($encoding) . '?' . $transfer_encoding . '?';
    $str = mb_convert_encoding($str, $encoding, mb_internal_encoding());
    $length = 76 - strlen($head) - 4;
    if ($transfer_encoding == "B") {
        $str = _sub_encode_base64($str, $encoding, $length, $linefeed);
    } else {
        $str = _sub_quoted_printable_encode($str, $encoding, $length, $linefeed);
    }
    $ar = explode($linefeed, $str);
    $s = '';
    foreach ($ar as $element) {
        if ($element != '') {
            $s .= $head . $element . '?=' . $linefeed;
        }
    }
    return $s;
}
Exemplo n.º 4
0
 public function mimeName($encoding = 'UTF-8')
 {
     if (!isCharset($encoding)) {
         return Error::set('Error', 'stringParameter', '1.(encoding)');
     }
     return mb_preferred_mime_name($encoding);
 }
Exemplo n.º 5
0
<?php

var_dump(mb_http_input());
var_dump(mb_http_output());
var_dump(mb_language());
var_dump(mb_preferred_mime_name("sjis-win"));
mb_regex_encoding("UTF-8");
var_dump(mb_regex_encoding());
var_dump(mb_regex_set_options());
var_dump(mb_regex_set_options("pz"));
var_dump(mb_regex_set_options());
Exemplo n.º 6
0
 public function preferredMimeName(string $encoding = 'UTF-8') : string
 {
     return mb_preferred_mime_name($encoding);
 }
Exemplo n.º 7
0
 /**
  * 履歴ファイルダウンロード
  *
  * @param none
  *
  * @return none
  */
 function download_history_file($file_history_id, $mode = '')
 {
     $file_history_row = ACSFileHistory::get_file_history_row($file_history_id);
     // ファイルパス
     if ($mode == 'thumb') {
         $file_path = $file_history_row['thumbnail_server_file_name'];
     } else {
         $file_path = $file_history_row['server_file_name'];
     }
     // ファイルが読み込みできない場合
     if (!is_readable(ACS_FOLDER_DIR . $file_path)) {
         header("Cache-Control: public, max-age=0");
         header("Pragma:");
         echo "Not Found";
         return;
     }
     // ダウンロードファイル名
     //		$download_file_name = mb_convert_encoding($this->get_display_file_name(), mb_http_output());
     $download_file_name = $this->get_display_file_name();
     // Content-type
     $content_type = $file_history_row['mime_type'];
     if ($content_type == '') {
         $content_type = 'application/octet-stream';
     }
     // charset (textの場合)
     if (preg_match('/text/', $content_type)) {
         $str = implode('', file(ACS_FOLDER_DIR . $file_path));
         $encoding = mb_detect_encoding($str, 'auto');
         if ($encoding == 'ASCII' && mb_http_output() != 'pass') {
             $content_type .= "; charset=" . mb_preferred_mime_name(mb_http_output());
         } else {
             $content_type .= "; charset=" . mb_preferred_mime_name($encoding);
         }
     }
     // action: inline(ブラウザ内表示), attachment(ダウンロードダイアログ)
     //if (preg_match('/text|image/', $content_type)) {
     if (preg_match('/image/', $file_history_row['mime_type']) || preg_match('/text/', $file_history_row['mime_type'])) {
         $action = 'inline';
     } else {
         $action = 'attachment';
     }
     // HTTPヘッダを吐く (action: inline, attachment)
     //		header("Content-disposition: $action; filename=\"$download_file_name\"");
     header("Content-disposition: {$action}; attachment; filename=\"" . ACSFile::get_download_name($download_file_name) . '"');
     header("Content-type: {$content_type}");
     // output_bufferingを無効にする
     mb_http_output('pass');
     if ($mode == 'thumb') {
         header("Cache-Control: public, max-age=1800");
         header("Pragma:");
     } else {
         header("Cache-Control: public, max-age=0");
         header("Pragma:");
     }
     // ファイルを読み出す
     readfile(ACS_FOLDER_DIR . $file_path);
 }
 /**
  * @param  string  $string
  * @return mixed
  */
 private function getCharsetFromCType($string)
 {
     $array = explode(';', $string);
     /* array_walk($array, create_function('$item', 'return trim($item);')); */
     if (isset($array[1])) {
         $array = explode('=', $array[1]);
         if (isset($array[1])) {
             $charset = trim($array[1]);
             if (preg_match('/^UTF-?8$/i', $charset)) {
                 return 'UTF-8';
             } elseif (function_exists('mb_preferred_mime_name')) {
                 return @mb_preferred_mime_name($charset);
             } else {
                 return $charset;
             }
         }
     }
     return false;
 }
 /**
  * Get Charset From Ctype
  *
  * @param  string $string
  * @return mixed
  */
 protected function _getCharsetFromCType($string)
 {
     $array = explode(';', $string);
     if (isset($array[1])) {
         $array = explode('=', $array[1]);
         if (isset($array[1])) {
             $charset = trim($array[1]);
             if (preg_match('/^UTF-?8$/i', $charset)) {
                 return 'UTF-8';
             } else {
                 // force preferred_mime_name in CharsetFromCType
                 $preferred = @mb_preferred_mime_name($charset);
                 return $preferred ? $preferred : $charset;
             }
         }
     }
     return false;
 }
Exemplo n.º 10
0
 /**
  * @ignore
  */
 public static function getEncoding()
 {
     return mb_preferred_mime_name(mb_internal_encoding());
 }
Exemplo n.º 11
0
<?php

// TODO: Add more encoding names
//$debug=true;
ini_set('include_path', dirname(__FILE__));
include_once 'common.inc';
$str = mb_preferred_mime_name('sjis-win');
echo "{$str}\n";
$str = mb_preferred_mime_name('SJIS');
echo "{$str}\n";
$str = mb_preferred_mime_name('EUC-JP');
echo "{$str}\n";
$str = mb_preferred_mime_name('UTF-8');
echo "{$str}\n";
$str = mb_preferred_mime_name('ISO-2022-JP');
echo "{$str}\n";
$str = mb_preferred_mime_name('JIS');
echo "{$str}\n";
$str = mb_preferred_mime_name('ISO-8859-1');
echo "{$str}\n";
$str = mb_preferred_mime_name('UCS2');
echo "{$str}\n";
$str = mb_preferred_mime_name('UCS4');
echo "{$str}\n";
echo "== INVALID PARAMETER ==\n";
// Invalid name
$r = mb_preferred_mime_name('BAD_NAME');
$r === FALSE ? print "OK_BAD_NAME\n" : (print "NG_BAD_NAME\n");
?>