> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/compute/guides-for-server-management/converting-files-from-iso-8859-1-to-utf-8.md).

# Converting files from ISO-8859-1 to UTF-8

***

Many websites are still encoded in ISO‑8859‑1. If you want to convert all the text in a file from ISO‑8859‑1 to UTF‑8, you can use the **iconv** utility, which is included in most Linux distributions.

The following command converts a single file from ISO-8859-1 to UTF-8:

{% code title="Command" %}

```
iconv -f iso-8859-1 -t utf-8 file1 > file2
```

{% endcode %}

The script below converts all text files (PHP, JS, CSS, HTML, and TXT) within a directory from ISO-8859-1 to UTF-8. The script should be executed from outside the directory to convert; it will then create a new directory with the prefix `utf8.`. For example, if you were to run `./iconvall.sh www/`, it would create `utf8.www` in the current working directory, where all text files are converted, and non-text files are copied. The directory structure in `utf8.www` will be identical to `www`.

The script looks like this:

{% code title="iconvall.sh" %}

```bash
#!/bin/bash
if [ $# -ne 1 ]
then
        echo "Script requires one argument, the folder to be converted from iso to utf."
        exit
fi

mkdir utf8.$1
cd utf8.$1
(cd ../$1; find -type d ! -name .) | xargs mkdir
cd ..
for i in `find $1 -type f -print`;
do
            #converts text files
            if [[ $i == *.php ]] || [[ $i == *.js ]] || [[ $i == *.css ]] || [[ $i == *.html ]] || [[ $i == *.txt ]]
            then
            echo "[CONVERT]: $i";
            iconv -f ISO-8859-1 -t UTF-8 $i -o utf8.$i;
            else
                echo "[COPY]: $i";
                cp $i utf8.$i
            fi
done
```

{% endcode %}

## Example

<pre data-title="Multiple commands and output. Commands are highlighted."><code><strong>./iconvall.sh www
</strong>[CONVERT]: www/index.html
[CONVERT]: www/subfolder/anothertext.txt
[COPY]: www/subfolder/anotherimage.jpg
[COPY]: www/image.jpg
[CONVERT]: www/story.txt
<strong>ls
</strong>iconvall.sh  utf8.www  www
<strong>tree
</strong>.
├── iconvall.sh
├── utf8.www
│   ├── image.jpg
│   ├── index.html
│   ├── story.txt
│   └── subfolder
│       ├── anotherimage.jpg
│       └── anothertext.txt
└── www
    ├── image.jpg
    ├── index.html
    ├── story.txt
    └── subfolder
        ├── anotherimage.jpg
        └── anothertext.txt

5 directories, 11 files
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glesys.com/products/compute/guides-for-server-management/converting-files-from-iso-8859-1-to-utf-8.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
