本文目錄一覽:
- 1、求可以將「PHP格式文件」轉換成為常用「視頻」格式的軟體(圖)
- 2、如何phpcb批量轉換的php程序
- 3、php中編碼轉換問題
- 4、淺析PHP中的字元串編碼轉換(自動識別原編碼)
- 5、php 編碼轉換
求可以將「PHP格式文件」轉換成為常用「視頻」格式的軟體(圖)
.php不是視頻文件格式,它是超文本預處理語言的縮寫,也是一種文本文件。
之所以你下載的視頻會變成這個格式,應該是下載中將擴展名改變了,或者是提供下載的有意更改了擴展名。
要知道它正確的擴展名,很簡單,用播放器打開後,右鍵打開屬性菜單,在文件信息或視頻編碼信息中就可以看到它真實的格式,再直接改回來就行了,不必用軟體轉換。
如何phpcb批量轉換的php程序
把phpCB.exe放在windows/system32/目錄下,php執行程序和要轉換的文件夾放同一級路徑,先配置$topath,然後在瀏覽器里訪問本程序,沒有結果輸出。
php中編碼轉換問題
function uc2html($str) {
$ret = ‘ ‘;
for( $i=0; $i strlen($str)/2; $i++ ) {
$charcode = ord($str[$i*2])+256*ord($str[$i*2+1]);
$ret .= iconv( “utf-8 “, “gb2312 “,u2utf8($charcode));
}
return $ret;
}
function u2utf8($c) {
$str= ” “;
if ($c 0x80) {
$str.=$c;
} else if ($c 0x800) {
$str.=chr(0xC0 | $c 6);
$str.=chr(0x80 | $c 0x3F);
} else if ($c 0x10000) {
$str.=chr(0xE0 | $c 12);
$str.=chr(0x80 | $c 6 0x3F);
$str.=chr(0x80 | $c 0x3F);
} else if ($c 0x200000) {
$str.=chr(0xF0 | $c 18);
$str.=chr(0x80 | $c 12 0x3F);
$str.=chr(0x80 | $c 6 0x3F);
$str.=chr(0x80 | $c 0x3F);
}
return $str;
}
如果你不是smarty的話 試試這個 如果是smarty的話 用下面的方法
?php
/*
@Author: 蝸牛
@Blog:
@Note: 這個解決辦法是基於上面那個地址提到的方法,解決了中英文截取長度時出現亂碼的問題
*/
function smarty_modifier_truncate($string, $sublen = 80, $etc = ‘…’, $break_words = false, $middle = false)
{
$start=0;
$code=”UTF-8″;
if($code == ‘UTF-8’)
{
//如果有中文則減去中文的個數
$cncount=cncount($string);
if($cncount($sublen/2))
{
$sublen=ceil($sublen/2);
}
else
{
$sublen=$sublen-$cncount;
}
$pa = “/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/”;
preg_match_all($pa, $string, $t_string);
if(count($t_string[0]) – $start $sublen) return join(”, array_slice($t_string[0], $start, $sublen)).”…”;
return join(”, array_slice($t_string[0], $start, $sublen));
}
else
{
$start = $start*2;
$sublen = $sublen*2;
$strlen = strlen($string);
$tmpstr = ”;
for($i=0; $i$strlen; $i++)
{
if($i=$start $i($start+$sublen))
{
if(ord(substr($string, $i, 1))129)
{
$tmpstr.= substr($string, $i, 2);
}
else
{
$tmpstr.= substr($string, $i, 1);
}
}
if(ord(substr($string, $i, 1))129) $i++;
}
if(strlen($tmpstr)$strlen ) $tmpstr.= “…”;
return $tmpstr;
}
}
function cncount($str)
{
$len=strlen($str);
$cncount=0;
for($i=0;$i$len;$i++)
{
$temp_str=substr($str,$i,1);
if(ord($temp_str) 127)
{
$cncount++;
}
}
return ceil($cncount/3);
}
?
是可以的以上兩種方法 site:
淺析PHP中的字元串編碼轉換(自動識別原編碼)
複製代碼
代碼如下:
/**
*
對數據進行編碼轉換
*
@param
array/string
$data
數組
*
@param
string
$output
轉換後的編碼
*/
function
array_iconv($data,$output
=
‘utf-8’)
{
$encode_arr
=
array(‘UTF-8′,’ASCII’,’GBK’,’GB2312′,’BIG5′,’JIS’,’eucjp-win’,’sjis-win’,’EUC-JP’);
$encoded
=
mb_detect_encoding($data,
$encode_arr);//自動判斷編碼
if
(!is_array($data))
{
return
mb_convert_encoding($data,
$output,
$encoded);
}
else
{
foreach
($data
as
$key=$val)
{
if(is_array($val))
{
$data[$key]
=
array_iconv($val,
$input,
$output);
}
else
{
$data[$key]
=
mb_convert_encoding($data,
$output,
$encoded);
}
}
return
$data;
}
}
php 編碼轉換
URLEncode:是指針對網頁url中的中文字元的一種編碼轉化方式,最常見的就是Baidu、Google等搜索引擎中輸入中文查詢時候,生成經過Encode過的網頁URL。
URLEncode的方式一般有兩種,一種是傳統的基於GB2312的Encode(Baidu、Yisou等使用),另一種是基於UTF-8的Encode(Google、Yahoo等使用)。
本工具分別實現兩種方式的Encode與Decode:
中文
–
GB2312的Encode
–
%D6%D0%CE%C4
中文
–
UTF-8的Encode
–
%E4%B8%AD%E6%96%87
我們可以用以下代碼實現轉換:
?php
echo
urlencode(‘測試’);?
如果是gb2312編碼,轉換的結果為”%B2%E2%CA%D4″;
如果是utf-8編碼,轉換的結果為”%E6%B5%8B%E8%AF%95″;
希望我的回答你能滿意啊!呵呵!
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/191110.html