Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

gftp 2.0.18 remote_charset 修正
post by tommy @ 25 二月, 2005 15:34
修改一下 gftp 在處理 remote_charsets 的錯誤

由於 gftp 內部在處理資料時, 似乎都轉成 utf-8 處理, 但是程式中這部份的邏輯似乎有點怪怪的, 除了在 remote_charsets 有設定時, 會把所有送出給 remote 的資料由 utf-8 再轉成所設定的編碼, 也會把由 remote 收到的資料由 remote_charsets 所設定的編碼轉成 utf-8 外, 對於 local (還有其他非 ftp 協定?), 也一直呼叫相同的函式來處理. (看不出有什麼判斷來決定那些要轉, 那些不用轉, 所以... 有些不該轉的也轉了... 有些該轉的, 又做了兩次轉換, 又轉回去原本的編碼) 

原本打算把 gftp 修改成符合 rfc-2640.

  1. 連線時送出 FEAT 指令, 判斷對方是否支援 rfc-2640. 也就是有 UTF8 feature.
  2. 如果對於有支援 rfc-2640, 則不要使用 remote_charsets 的設定來轉碼. 應直接使用 utf-8.
  3. 所有 local 端的檔名, 再由 utf-8 <-> local 之間互轉.

不過... 有些邏輯看了一上午, 實在看不太出來. 所以決定就用最簡單的改法. 就是假定 local 端一律使用 utf-8, 檔案儲存的時候, 如果檔名非 utf-8 就轉成 utf-8. 這個改法並非每個人都適用, 如果你的 locale 並沒設定為 utf-8, 應該會有問題.

改了之後:

  1. 如果 ftp server 使用 utf-8, 則不管 gftp 使用 big5 或 utf-8 都可以正常看到中文.
  2. 如果 ftp server 使用 big5, 則在 remote_charsets 中有設定 big5 的話, 也可以正常看到中文.
  3. 在指令的部份, dir 或 get 都可以輸入中文字當參數.
  4. 不管 gftp 在什麼環境下執行, big5 or utf-8 or 其它, 所有 local 端的檔名, 都會使用 utf-8 處理.

也就是說, 如果你不是在 utf-8 的環境下頭的話, 最好不要用這個版本. 以免在 local 找不到 big5 的中文檔名, 抓回來的中文檔名也變成 utf-8 編碼. 我試過 gftp-text/gftp-gtk 兩個版本, 都可以正常使用. 只是有些傳送的訊息, 可能會出現 big5 碼, 會有轉碼失敗的錯誤訊息, 應該不會影響正常使用.

patch 檔案在:
http://www.teatime.com.tw/~tommy/linux/gftp_remote_charsets.patch

給 sarge 用的 deb 在這兒:
http://www.teatime.com.tw/~tommy/debian/gftp_2.0.18-9_all.deb
http://www.teatime.com.tw/~tommy/debian/gftp-gtk_2.0.18-9_i386.deb
http://www.teatime.com.tw/~tommy/debian/gftp-common_2.0.18-9_i386.deb
http://www.teatime.com.tw/~tommy/debian/gftp-text_2.0.18-9_i386.deb
 

Del.icio.us Furl HEMiDEMi Technorati MyShare
commons icon [1] 請問gftp_remote_charsets.patch如何使用? [ 回覆 ]

您好,很感謝您提供這個patch,不過小弟我是個linux新手,不太曉得如何使用這個patch,我嘗試在/usr/bin當中下達patch -p0 < gftp_remote_charsets.patch,出現如下error:

can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -Nur gftp-2.0.18/lib/local.c gftp-2.0.18.patched/lib/local.c
|--- gftp-2.0.18/lib/local.c 2005-02-02 09:24:51.000000000 +0800
|+++ gftp-2.0.18.patched/lib/local.c 2005-02-28 14:41:00.000000000 +0800
--------------------------
File to patch:
Skip this patch? [y]

請問該如何正確使用這個patch呢?非常感激您的回應!

commons icon [2] [ 回覆 ]

請在 gftp 的 source code 所在的目錄下執行 patch -p1 < gftp_remote_charsets.patch

迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 139 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS