「ファイルをUTF-8に変換する」の版間の差分

提供:MoodleDocs
移動先:案内検索
11行目: 11行目:


==Windowsコンピュータ==
==Windowsコンピュータ==
Windows用のフリーのツールは存在しません。しかし、[[http://www.cygwin.com Cygwin]]を使用することで変換作業を行うことができます。 [[http://www.cygwin.com Cygwin]]は、Windows用のLinux-like環境で、iconvコマンドを実行することができます。
Windows用のフリーのツールは存在しません。しかし、[http://www.cygwin.com Cygwin]を使用することで変換作業を行うことができます。 [http://www.cygwin.com Cygwin]は、Windows用のLinux-like環境で、iconvコマンドを実行することができます。


Windowsで[[http://www.cygwin.com Cygwin]]を使用した解決策の例:
Windowsで[http://www.cygwin.com Cygwin]を使用した変換方法例:


* ToUtf8.txtという名称のテキストファイルを作成します。
* ToUtf8.txtという名称のテキストファイルを作成します。

2006年8月24日 (木) 23:39時点における版

Moodle 1.6


翻訳中です - Mitsuhiro Yoshida 2006年8月24日 (木) 18:29 (CDT)

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

*nix 等のコンピュータ

一般的に、Unix、LinuxまたはMacでは、iconvコマンドで変換します。

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

Windowsコンピュータ

Windows用のフリーのツールは存在しません。しかし、Cygwinを使用することで変換作業を行うことができます。 Cygwinは、Windows用のLinux-like環境で、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

Two things should be changed for your local situation:

  1. FROM is the originating encoding (the one your original files are in)
  2. 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!
  • Start 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.
  • Execute the script by typing sh ToUtf8.txt and your files will be converted.