forked from tobychui/arozos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
["ArOZ-Online 編碼器"] | ||
![](img/devdoc/6/0.png) | ||
# ArOZ Online 編碼器 | ||
為了支援大部份語言,ArOZ Online會對存儲在ArOZ根目錄及外部存儲空間中的所有文件和資料夾名使用全新的名稱編碼方法。 | ||
|
||
此方法首先於Upload Manager模組中使用,本方法成功解決了Window系統上UTF-8檔案名無法上傳的問題。 因此,檔案名和文件夾名被命名為“um-file方法”(或umfilename的縮寫)。 | ||
|
||
## UM檔案名和HexFoldername | ||
UMFilename由三部分組成。結構如下: | ||
```inith{filename_name_after_bin2hex}。{EXT}``` | ||
|
||
其中“ inith”表示以十六進制開頭。 | ||
|
||
|
||
##基於PHP的轉換 | ||
以下部分說明了將umfilename和從umfilename轉換為UTF-8檔案名的方法。 | ||
|
||
### UTF-8檔案名到UM檔案名 | ||
這是將UTF-8檔案名/文件夾名轉換為umfilename / hexfoldername的方法。 | ||
|
||
``` | ||
//Convert file | ||
$ext = pathinfo($filename, PATHINFO_EXTENSION); | ||
$fname = basename($filename, "." .$ext); | ||
$umfilename = "inith" . bin2hex($fname) . $ext; | ||
//Convert folder | ||
$hexfoldername = bin2hex(basename($foldername)); | ||
``` | ||
|
||
### UM檔案名轉換為UTF-8檔案名 | ||
要將UM檔案名轉換回UTF-8文件名,您可以使用以下代碼。 | ||
|
||
``` | ||
//Convert file | ||
if (substr(basename($filename),0,5) === "inith"){ | ||
$ext = pathinfo($filename, PATHINFO_EXTENSION); | ||
$orgname = str_replace("inith","",basename($filename,"." . $ext)); | ||
if (ctype_xdigit($orgname) && strlen($orgname) % 2 == 0) { | ||
$orgname = hex2bin($orgname); | ||
} | ||
$decodedName = dirname($filename) . "/" . $orgname . "." . $ext; | ||
} | ||
//Convert folder | ||
if (ctype_xdigit($foldername) && strlen($foldername) % 2 == 0) { | ||
$decodedName = hex2bin($foldername); | ||
} | ||
``` | ||
|
||
##基於JavaScript的轉換 | ||
|
||
從Beta開始,ao_module中的ao_module_codec就支援基於Javascript的umfilename解碼。 要使用它們,只需引用並調用下面的函數。 | ||
``` | ||
ao_module_codec.decodeUmFilename(umfilename_here); | ||
ao_module_codec.decodeHexFoldername(hexFolderName_here); | ||
``` | ||
|
||
*請注意,ao_module包裝器不支援將UTF-8檔案名到UM檔案名。 您應該避免在客戶端執行um-file編碼,而且umfilename的原目的是解決伺服器端的本地化問題。* | ||
|
||
## UMfilename檔案瀏覽器中的HexFoldername | ||
UMFilename和HexFoldername以易於閱讀的格式顯示在ArOZ Online中的檔案瀏覽器中。 | ||
![](img/devdoc/6/1.png) | ||
|
||
對於Linux文件系統(或Windows NTFS,如果在Windows上使用系統),若編碼是umfilename或hexfoldername,該文件的背景顏色將更新為其他顏色。 顏色如下。 | ||
|
||
<table class="ts table"> | ||
<THEAD> | ||
<TR> | ||
<th>e檔案命名方法</ th> | ||
<th>編碼方式</ th> | ||
<th>顏色</ th> | ||
</ TR> | ||
</ THEAD> | ||
<TBODY> | ||
<TR> | ||
<td>預設(UTF-8)</ td> | ||
<TD>無</ TD> | ||
<TD>白</ TD> | ||
</ TR> | ||
<TR> | ||
<TD> UM-文件名</ TD> | ||
<td>“ inith” + bin2hex({original_filename})+“。 + {original_ext} </ td> | ||
<TD>藍</ TD> | ||
</ TR> | ||
<TR> | ||
<TD> HEX-資料夾名稱</ TD> | ||
<TD> BIN2HEX({original_foldername})</ TD> | ||
<TD>綠色</ TD> | ||
</ TR> | ||
</ TBODY> | ||
</ TABLE> | ||
|
||
##使用fsconv進行轉換 | ||
請參閱File Systen API,了解應如何使用fsconv轉換AO-Codec檔案的文件名。 |