Sealyu

          --- 博客已遷移至: http://www.sealyu.com/blog

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

          問題就是我們使用TextMate不支持GB2312等編碼,用著及其不方便,下面是解決方案:

          打開Bundle Editor
          選則Show all

          選則文件夾TextMate(或者隨便你選則什么)
          增加一個新的template‘openEncodedFile’(或者隨便你自己命名)
          在Template data中如下設(shè)定
          Extension:中 留空

          Command(s):

          # open CocoaDialog’s file select menu

          file=$(CocoaDialog fileselect \
          --title "Open an encoded file" \
          --with-directory $HOME/ \
          )
          # check for valid file
          if [ -n "$file" ]; then
          # open CocoaDialog's dropdown menu
          # for more encodings add them to '--items'
          # to list all possibile encodings use the Terminal with 'iconv -l'
          res=$(CocoaDialog dropdown \
          --title "Open an encoded file" \
          --text "Choose the encoding:" \
          ??exit?onchange \
          --button1 "Open" \
          --button2 "Cancel" \
          --items "BIG5" "EUC-TW" "GB2312" "SJIS" "EUC-JP" "KOI8-R" \
          )
          # if user canceled exit
          [[ $( (tail -r <<<"$res") | tail -n1) == "2" ]] && \
          exit_discard
          res=$(tail -n1 <<<"$res")
          # add more 'elif' according to '--items' if needed
          if [ "$res" == 0 ]; then
          ENC="BIG5"
          elif [ "$res" == 1 ]; then
          ENC="EUC-TW"
          elif [ "$res" == 2 ]; then
          ENC="GB2312"
          elif [ "$res" == 3 ]; then
          ENC="SJIS"
          elif [ "$res" == 4 ]; then
          ENC="EUC-JP"
          elif [ "$res" == 5 ]; then
          ENC="KOI8-R"
          fi
          # start conversion to UTF-8 and send the result as a new file back to TM
          iconv -f "$ENC" -t utf-8 "$file" > "$TM_NEW_FILE"
          fi
          Output: Insert as Text - Activation: Key Equivalent shift+option+o (我的建議) - Scope: 留空

          posted on 2010-09-08 19:40 seal 閱讀(563) 評論(0)  編輯  收藏 所屬分類: Apple
          主站蜘蛛池模板: 随州市| 东方市| 和硕县| 民权县| 青州市| 炉霍县| 禄丰县| 奎屯市| 平凉市| 府谷县| 周口市| 平江县| 广州市| 海城市| 山西省| 建瓯市| 洪湖市| 长岛县| 昌图县| 嘉荫县| 泰州市| 曲周县| 彰化市| 荆州市| 缙云县| 乌兰县| 红河县| 上杭县| 稷山县| 靖西县| 通化县| 桂平市| 专栏| 抚远县| 汕头市| 青神县| 航空| 黄骅市| 延长县| 成安县| 集贤县|