「ファイルをUTF-8にコンバートする」の版間の差分

提供:MoodleDocs
移動先:案内検索
(新しいページ: '{{Moodle 1.6}} 作成中です - ~~~~ Some files, like custom language packs or language files from third party modules need to be converted to UTF-8 before they may be used ...')
 
(done.)
 
(同じ利用者による、間の9版が非表示)
1行目: 1行目:
{{Moodle 1.6}}
{{Moodle 1.6}}


作成中です - [[利用者:Mitsuhiro Yoshida|Mitsuhiro Yoshida]] 2008年8月10日 (日) 15:11 (CDT)
カスタム言語パック、またはサードパーティモジュールの言語ファイル等は、Moodle 1.6のUTF-8データベースで使用する前に、UTF-8にコンバートする必要があります。


Some files, like custom language packs or language files from third party modules need to be converted to UTF-8 before they may be used in Moodle 1.6 with UTF-8 database.
==*nix likeコンピュータ (Mac OS Xを含む)==
 
一般的にUnix、Linux、Macの「iconv」コマンドを使用してコンバートします。
==*nix like computers (including Mac OS X)==
Generally, this may be done with the ''iconv'' command on Unix, Linux or a Mac.


<code>iconv -f original_charset -t utf-8 originalfile > newfile</code>
<code>iconv -f original_charset -t utf-8 originalfile > newfile</code>


''see also the windows explanation - the script there is one for *nix computers, but used in a cygwin environment''
Windowsコンピュータに関する説明もご覧ください - ここでのスクリプトは*nixコンピュータのものですが、cygwin環境で使用します。


==Windows computers==
==Windowsコンピュータ==
For Windows, there are three methods of performing the conversion.
Windowsでは、UTF-8へのコンバートに3つの方法があります。


=== 方法1 ===
=== 方法1 ===
* Open the flat file in PSPad (a freeware editor) : http://www.pspad.com
* フラットファイルをサクラエディタ (http://sakura_editor.at.infoseek.co.jp/) で開いてください。
* Click on Format, UTF-8
* ファイル(F) >> 名前を付けて保存(A) を選択してください。
* Save the file
* 文字コードセットをUTF-8、改行コードをLF (Unix) にしてください。
* 保存(S) をクリックして、ファイルを保存してください。
 
または
 
* フラットファイルをPSPad (http://www.pspad.com) で開いてください。
* Formatメニューをクリックして、UTF-8を選択してください。
* ファイルを保存してください。


=== 方法2 ===
=== 方法2 ===
Download the [http://gnuwin32.sourceforge.net/packages/libiconv.htm Windows version] of the iconv program. Download the "Complete package, except source" and run the setup program. The executable is located in the bin folder. Run from the command prompt (Start -> Run -> cmd) and follow the instructions as above.
[http://gnuwin32.sourceforge.net/packages/libiconv.htm Windowsバージョン]のiconvプログラムをダウンロードしてください。「Complete package, except sources」をダウンロードして、セットアッププログラムを実行してください。実行ファイルは、binfフォルダに入っています。実行ファイルをコマンドプロンプトから実行 (スタート >> ファイル名を指定して実行(R) >> 名前(O)) して、上記インストラクションに従ってください。


=== 方法3 ===
=== 方法3 ===
The conversion may also be done by using [http://www.cygwin.com Cygwin], a Linux-like environment for Windows, and excecuting the iconv command in that environment. Here is an example of a working solution on Windows with [http://www.cygwin.com Cygwin]:
Windows用Linux-like環境の[http://www.cygwin.com Cygwin]でiconvコマンドを実行することにより、コンバージョンすることもできます。以下、Windowsで[http://www.cygwin.com Cygwin]を使用したコンバージョンの例です:


* Create a text file, named ToUtf8.txt
* ToUtf8.txtという名称のテキストファイルを作成してください。
* Fill it with the following code
* 作成したテキストファイルに次のコードを記述してください。


<pre>#!/bin/bash
<pre>#!/bin/bash
40行目: 45行目:
done</pre>
done</pre>


Two things should be changed for your local situation:
あなたの環境に応じて、下記2点を変更してください:


# FROM is the originating encoding (the one your original files are in)
# 「FROM」は、あなたのファイルのオリジナルエンコーディングです。
# ToUTF is the foldername where the files that need to be converted are in. This folder may contain subfolders. Make sure you have a backup!
# 「ToUTF」は、コンバートするファイルが入っているフォルダ名です。フォルダには、サブフォルダを含むことができます。忘れずにファイルをバックアップしてください!


* Start Cygwin.
* Cygwinを開始してください。
* With the ''cd foldername, cd.., ls'' commands, go to the folder on your windows machine where the ToUtf8.txt script and the ToUTF8 folder are in.
* ''cd foldername, cd.., ls'' コマンドを使って、ToUtf8.txtおよびToUTF8フォルダが入っているフォルダに移動してください。
* Execute the script by typing ''sh ToUtf8.txt'' and your files will be converted.
* ''sh ToUtf8.txt'' と入力してスクリプトを実行してください。あなたのファイルがコンバートされます。


[[Category:管理者]]
[[Category:管理者]]

2008年8月14日 (木) 15:08時点における最新版

Moodle 1.6


カスタム言語パック、またはサードパーティモジュールの言語ファイル等は、Moodle 1.6のUTF-8データベースで使用する前に、UTF-8にコンバートする必要があります。

*nix likeコンピュータ (Mac OS Xを含む)

一般的にUnix、Linux、Macの「iconv」コマンドを使用してコンバートします。

iconv -f original_charset -t utf-8 originalfile > newfile

Windowsコンピュータに関する説明もご覧ください - ここでのスクリプトは*nixコンピュータのものですが、cygwin環境で使用します。

Windowsコンピュータ

Windowsでは、UTF-8へのコンバートに3つの方法があります。

方法1

  • フラットファイルをサクラエディタ (http://sakura_editor.at.infoseek.co.jp/) で開いてください。
  • ファイル(F) >> 名前を付けて保存(A) を選択してください。
  • 文字コードセットをUTF-8、改行コードをLF (Unix) にしてください。
  • 保存(S) をクリックして、ファイルを保存してください。

または

  • フラットファイルをPSPad (http://www.pspad.com) で開いてください。
  • Formatメニューをクリックして、UTF-8を選択してください。
  • ファイルを保存してください。

方法2

Windowsバージョンのiconvプログラムをダウンロードしてください。「Complete package, except sources」をダウンロードして、セットアッププログラムを実行してください。実行ファイルは、binfフォルダに入っています。実行ファイルをコマンドプロンプトから実行 (スタート >> ファイル名を指定して実行(R) >> 名前(O)) して、上記インストラクションに従ってください。

方法3

Windows用Linux-like環境のCygwinでiconvコマンドを実行することにより、コンバージョンすることもできます。以下、WindowsでCygwinを使用したコンバージョンの例です:

  • ToUtf8.txtという名称のテキストファイルを作成してください。
  • 作成したテキストファイルに次のコードを記述してください。
#!/bin/bash
FROM=iso-8859-1
TO=UTF-8
ICONV="iconv -f $FROM -t $TO"
# Convert
find ToUTF/ -type f -name "*" | while read fn; do
cp ${fn} ${fn}.bak
$ICONV < ${fn}.bak > ${fn}
rm ${fn}.bak
done

あなたの環境に応じて、下記2点を変更してください:

  1. 「FROM」は、あなたのファイルのオリジナルエンコーディングです。
  2. 「ToUTF」は、コンバートするファイルが入っているフォルダ名です。フォルダには、サブフォルダを含むことができます。忘れずにファイルをバックアップしてください!
  • Cygwinを開始してください。
  • cd foldername, cd.., ls コマンドを使って、ToUtf8.txtおよびToUTF8フォルダが入っているフォルダに移動してください。
  • sh ToUtf8.txt と入力してスクリプトを実行してください。あなたのファイルがコンバートされます。