• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンd53c4f3350f9e85274596ad07229a0ffe8d3130c (tree)
日時2014-12-22 23:41:59
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

Implement converting UTF-8 source code to EUC-JP dist files

Convert option sample:

for UTF-8 to UTF-8:

$ ./release.sh --utf8

for UTF-8 to EUC-JP:

$ ./release.sh --eucjp

for EUC-JP to UTF-8:

$ ./release.sh --utf8 --fromeucjp

for EUC-JP to EUC-JP:

$ ./release.sh --eucjp --fromeucjp

変更サマリ

差分

--- a/release.sh
+++ b/release.sh
@@ -18,7 +18,9 @@ usage(){
1818 warn " --nopkg Suppress creating archive (Extract and chmod only)"
1919 warn " --norm --nopkg, and remove nothing (.cvsignore etc)"
2020 warn " --co --norm, and use 'checkout' command instead of 'export'"
21- warn " --utf8 Create UTF-8 converted archive (EXPERIMENTAL)"
21+ warn " --utf8 Create UTF-8 converted archive"
22+ warn " --eucjp Create EUC_JP converted archive"
23+ warn " --fromeucjp Indicate source charset is EUC_JP"
2224 warn " -z|--zip Create *.zip archive"
2325 warn " --move-dist Move *.ini.php => *.ini-dist.php"
2426 warn " --copy-dist Move, and Copy *.ini.php <= *.ini-dist.php"
@@ -88,6 +90,8 @@ getopt(){ _arg=noarg
8890 --co|--checkout ) echo _nopkg _noremove _checkout 1 ;;
8991 -z|--zip ) echo _zip 1 ;;
9092 --ut|--utf|--utf8|--utf-8 ) echo _utf8 1 ;;
93+ --eucjp ) echo _eucjp 1 ;;
94+ --fromeucjp ) echo _fromeucjp 1 ;;
9195 --copy-dist ) echo _copy_dist 1 ;;
9296 --move-dist ) echo _move_dist 1 ;;
9397 -d ) echo _CVSROOT 2 ; _arg="$2" ;;
@@ -134,7 +138,12 @@ if [ $# -eq 0 ] ; then usage ; exit ; fi
134138
135139 # Utility check ---------------------------------------------
136140
137-if [ "$__utf8" ] ; then
141+# Convert UTF-8 -> EUC_JP or EUC_JP -> UTF-8
142+if [ \( "$__eucjp" -a ! "$__fromeucjp" \) -o \( "$__utf8" -a "$__fromeucjp" \) ] ; then
143+ __charconv=1
144+fi
145+
146+if [ "$__charconv" ] ; then
138147
139148 # nkf
140149 which nkf || err "nkf version 2.0 or later (UTF-8 enabled) not found"
@@ -153,9 +162,13 @@ if [ "$__utf8" ] ; then
153162 fi
154163
155164 convert(){
165+ __nkfopt="--ic=eucJP-ms -w"
166+ if [ "$__eucjp" ] ; then
167+ __nkfopt="--ic=UTF8 --oc=eucJP-ms"
168+ fi
156169 for list in "$@" ; do
157170 # NOTE: Specify '-E'(From EUC-JP) otherwise skin file will be collapsed
158- nkf --ic=eucJP-ms -w "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list" && echo " $list"
171+ nkf $__nkfopt "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list" && echo " $list"
159172 done
160173 }
161174 convert_EUCJP2UTF8(){
@@ -165,6 +178,13 @@ if [ "$__utf8" ] ; then
165178 sed 's#^//UTF-8:##' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
166179 done
167180 }
181+ convert_UTF82EUCJP(){
182+ for list in "$@" ; do
183+ # Very rough conversion!
184+ #sed 's/EUC-JP/UTF-8/g' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
185+ sed 's#^\(.*//UTF-8 only\)$#//UTF-8:\0#' "$list" > "$list.$$.tmp" && mv "$list.$$.tmp" "$list"
186+ done
187+ }
168188 fi > /dev/null
169189
170190 if [ -z "$__zip" ]
@@ -241,8 +261,12 @@ mv $pkg_dir/cache/_recent.dat $pkg_dir/cache/recent.dat
241261
242262 # Conversion ------------------------------------------------
243263
244-if [ "$__utf8" ] ; then
245- echo "Converting EUC-JP => UTF-8 ..."
264+if [ "$__charconv" ] ; then
265+ if [ "$__utf8" ] ; then
266+ echo "Converting EUC-JP => UTF-8 ..."
267+ else
268+ echo "Converting UTF-8 => EUC-JP ..."
269+ fi
246270 find "$pkg_dir" -type f \( -name "*.txt" -or -name "*.php" -or -name "*.lng" -or -name "*.dat" -or -name "*.ref" \) |
247271 while read line; do
248272 case "$line" in
@@ -251,10 +275,17 @@ if [ "$__utf8" ] ; then
251275 esac
252276 done
253277
254- # Replace 'EUC-JP' => 'UTF-8'
255- ( cd "$pkg_dir" &&
256- convert_EUCJP2UTF8 lib/init.php skin/pukiwiki.skin*.php
257- )
278+ if [ "$__utf8" ] ; then
279+ # Replace 'EUC-JP' => 'UTF-8'
280+ ( cd "$pkg_dir" &&
281+ convert_EUCJP2UTF8 lib/init.php skin/pukiwiki.skin*.php
282+ )
283+ else
284+ # Replace 'UTF-8' => 'EUC-JP'
285+ ( cd "$pkg_dir" &&
286+ convert_UTF82EUCJP lib/init.php skin/pukiwiki.skin*.php
287+ )
288+ fi
258289
259290 # Filename encoded 'encoded-EUC-JP' to 'encoded-UTF-8'
260291 echo "Renaming encoded-EUC-JP => encoded-UTF-8 ..."