跳至內容
DokuWiki
It's better when it's simple
使用者工具
登入
網站工具
搜尋
工具
顯示頁面
舊版
反向連結
最近更新
多媒體管理器
網站地圖
登入
>
最近更新
多媒體管理器
網站地圖
足跡:
zh-tw:pagename
編輯本頁後,請按下「儲存」按鈕。若要參看語法說明,請到
語法
頁。請只在能讓本文品質
更好
時才編輯。如果只是要測試,請移玉步至
遊樂場
。
媒體檔案
====== 頁面名稱 ====== 簡單來說,頁面名稱(Pagename)就是wiki中那些頁面的名字。在DokuWiki實際的檔案架構中,頁面名稱就是會是那個頁面資料檔的檔案名稱。 在[[DokuWiki]]中,頁面名稱只可以使用英文字母、數字、以及''.''、''-''及''_''這些特殊符號。其他特殊符號會被自動轉換成底線"_",而大寫英文字母也會自動被轉換成小寫。 至於冒號":"則有特殊用途,它是用來區隔[[namespaces|分類名稱]]與頁面名稱的。 如果您使用中文(或中日韓字符)命名,它會被轉換成貌似亂碼的字符串,但其實那是特別的代碼。其它非英語系字母,通常會被轉換,像是"ü" 會變成 "ue"。儘管如此,只要Admin在 [[config]] 檔中正確設定 ''localname'',那這些非英語系的字母是允許出現的。詳情請參見[[multilanguage]] 頁面。 在wiki中任何一頁上方,你可以看到完整的頁面名稱。例如你現在應該看到的是''wiki:pagename''。 當你使用[[InterWiki]]的方法連結至其他的wiki,那命名就必須符合那些wiki所訂定的規則。 即使Admin在 [[config]] 中設定容許使用 [[wp>CamelCase]],頁面名稱還是必須要符合前述的命名方法。 ====== 關於中文頁面名稱亂碼的解決方法(一) ====== ===== 伺服器環境 ===== * windows XP Profession SP2 * Apache2.0.54 * PHP5.0.4 * PHP加載了mb_string模塊 ===== 解決辦法 ===== 這是一個不成熟的辦法,在分別測試了PmWiki與DokuWiki後,覺得DokuWiki很不錯。特別是它的存儲文本文件,直接打開也是清晰可讀的。比較遺憾的是,文件名是亂碼((其實不是亂碼,是進行了urlencode編碼,我們看不懂而已。))。為了解決這個問題,對\inc\<del>utf8.php</del>pageutils.php做以下就可以了,經過初步測試沒有問題: * 修改對文件名進行編碼、解碼的兩個函數:utf8_encodeFN、utf8_decodeFN <code php> function utf8_encodeFN($file,$safe=true){ if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ return $file; } /*我註釋掉的部分 $file = urlencode($file); $file = str_replace('%2F','/',$file);*/ //我增加的部分開始 $file=mb_convert_encoding($file,"CP950","UTF-8"); //我增加的部分結束 return $file; } function utf8_decodeFN($file){ /* 我註釋掉的部分 $file = urldecode($file);*/ //我增加的部分開始 if(preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ return $file; } $file=mb_convert_encoding($file,"UTF-8","CP950"); //我增加的部分結束 return $file; } </code> 以下是我的修改 <code> function utf8_encodeFN($file,$safe=true){ global $conf; if($conf['fnencode'] == 'utf-8') { $file=mb_convert_encoding($file,"CP936","UTF-8"); return $file;} if($safe && preg_match('#^[a-zA-Z0-9/_\-\.%]+$#',$file)){ return $file; } if($conf['fnencode'] == 'safe'){ return SafeFN::encode($file); } $file = urlencode($file); $file = str_replace('%2F','/',$file); return $file; } function utf8_decodeFN($file){ global $conf; if($conf['fnencode'] == 'utf-8') { $file=mb_convert_encoding($file,"UTF-8","CP936"); return $file;} if($conf['fnencode'] == 'safe'){ return SafeFN::decode($file); } return urldecode($file); } </code> * 對於不同的內碼,將"CP950"換成對應的代碼即可。 * CP936是簡體中文、CP950是繁體中文 這樣所有的中文連結都將以正確的中文文件名儲存了。 ===== BUG與缺點 ===== 目前知道的不足有以下一些: - 需要mb_string模塊支援; - 對文件名進行了編碼轉換,估計會影響運行的效率((不過對於資料庫細小的個人用戶來講,影響不大。)); - 當更換作業系統時,還需要增加內容,對文件名進行mb_detect_encoding處理; - 會和Tag plugin的index功能衝突,產生亂碼的index ====== 關於中文頁面名亂碼的解決辦法(二) ====== ===== 伺服器環境 ===== * windows XP Profession SP2 * IIS * PHP4 ===== 解決辦法 ===== 小弟受上面這位大哥的啟發,作了一下改進,現在可以不用mb_string模塊的支援了。經過初步測試沒有問題:\\ --- //[[jflycn@gmail.com|慕容飛宇]] 2006-04-14 07:15// * 需要從[[http://www.phpe.net/class/95.shtml]]下載Encoding類,解壓後放到dokuwiki的inc目錄下的encoding目錄中。 * 將encoding目錄中的encoding.inc.php文件中的「var $FilePath」修改為encoding類的完整路徑; * 對inc目錄下的utf8.php中的函數utf8_encodeFN和utf8_decodeFN作如下修改: <code php> require_once(DOKU_INC.'inc\encoding\encoding.inc.php'); function utf8_encodeFN($file,$safe=true){ if($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ return $file; } /*我註釋掉的部分 $file = urlencode($file); $file = str_replace('%2F','/',$file);*/ //我增加的部分開始 $CharEncoding=new Encoding(); $CharEncoding->SetGetEncoding("UTF-8")||die("編碼名錯誤"); $CharEncoding->SetToEncoding("GBK")||die("編碼名錯誤"); $file=$CharEncoding->EncodeString($file); //我增加的部分結束 return $file; } function utf8_decodeFN($file){ /* 我註釋掉的部分 $file = urldecode($file);*/ //我增加的部分開始 if(preg_match('#^[a-zA-Z0-9/_\-.%]+$#',$file)){ return $file; } $CharEncoding=new Encoding(); $CharEncoding->SetGetEncoding("GBK")||die("編碼名錯誤"); $CharEncoding->SetToEncoding("UTF-8")||die("編碼名錯誤"); $file=$CharEncoding->EncodeString($file); //我增加的部分結束 return $file; } </code> 這樣所有的中文連結都將以正確的中文文件名存儲了。 \\ \\ 大家有問題可以到[[discussion:chineseuserdiscussion|中文用戶討論組]]討論解決問題。 ---- ====== 關於中文頁面名亂碼的解決辦法——之Windows下亂碼 ====== ===== 伺服器環境 ===== * windows Server 2008R2 * Apache 2.2 * PHP 5 * dokuwiki-2010-11-07a.tgz “Anteater” 新版本可以直接設定編碼是UTF-8, safe或url (請參考[[http://www.dokuwiki.org/config:fnencode|config:fnencode]]) 但是windows還是使用big5作為目錄與檔名的編碼 如是在windows下,這三種方法還是得到亂碼 我作了以下的修改可以正常的運作 1.conf/local.php 修改$conf['fnencode'] = 'big5'; 2.inc/pageutils.php <code php> function utf8_encodeFN($file,$safe=true){ global $conf; ...略 if($conf['fnencode'] == 'safe'){ return SafeFN::encode($file); } //新增以下這段 if($conf['fnencode'] == 'big5'){ return mb_convert_encoding($file,'big5','UTF-8'); } //到這 $file = urlencode($file); $file = str_replace('%2F','/',$file); return $file; } ... function utf8_decodeFN($file){ global $conf; if($conf['fnencode'] == 'utf-8') return $file; if($conf['fnencode'] == 'safe'){ return SafeFN::decode($file); } //新增以下這段 if($conf['fnencode'] == 'big5'){ return mb_convert_encoding($file,'UTF-8','big5'); } //到這 return urldecode($file); return $file; } </code> 提供給大家參考 ---- 本頁面授權方式為[[http://creativecommons.org/licenses/by-nc-sa/2.0/|Creative Commons Attribution-NonCommercial-ShareAlike License Version 2.0. ]]
請將字母填入方框。
I L C A A
請保持這個欄位空白
儲存
預覽
取消
編輯摘要
注意:編輯此頁面表示您同意用以下授權方式發布您撰寫的內容:
CC Attribution-Share Alike 4.0 International
zh-tw/pagename.txt
· 上一次變更: 2015-01-21 01:44 由
ach
頁面工具
顯示頁面
舊版
反向連結
回到頁頂