Converting files to UTF-8: Difference between revisions
No edit summary |
Helen Foster (talk | contribs) m (formatting, categories) |
||
Line 1: | Line 1: | ||
Some files, like custom language packs or language files from | {{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 in Moodle 1.6 with UTF-8 database. | |||
==*nix like computers== | ==*nix like computers== | ||
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> | ||
==Windows computers== | ==Windows computers== | ||
For Windows, | For Windows, a free tool doesn't exist. However, the conversion may be done by using [[http://www.cygwin.com Cygwin]], a Linux-like environment for Windows, and excecuting the iconv command in that environment. | ||
Example of a working sollution on Windows with [[http://www.cygwin.com Cygwin]]: | Example of a working sollution on Windows with [[http://www.cygwin.com Cygwin]]: | ||
Line 15: | Line 14: | ||
* Create a text file, named ToUtf8.txt | * Create a text file, named ToUtf8.txt | ||
* Fill it with the following code | * Fill it with the following code | ||
< | <pre>#!/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</pre> | |||
Two things should be changed for your local situation: | |||
# FROM is the originating encoding (the one your original files are in) | |||
# 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. | * 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. | * 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. | * Execute the script by typing ''sh ToUtf8.txt'' and your files will be converted. | ||
[[Category:Administrator]] | |||
[[Category:Language]] | |||
[[Category:UTF-8]] |
Revision as of 07:49, 28 June 2006
Template: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 in Moodle 1.6 with UTF-8 database.
*nix like computers
Generally, this may be done with the iconv command on Unix, Linux or a Mac.
iconv -f original_charset -t utf-8 originalfile > newfile
Windows computers
For Windows, a free tool doesn't exist. However, the conversion may be done by using [Cygwin], a Linux-like environment for Windows, and excecuting the iconv command in that environment.
Example of a working sollution on Windows with [Cygwin]:
- Create a text file, named ToUtf8.txt
- Fill it with the following code
#!/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:
- FROM is the originating encoding (the one your original files are in)
- 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.