---
title: utf8.translate
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/unicode/utf8-translate
---

```
STRING utf8.translate(STRING input, STRING set1, STRING set2)
```

**Available in:** all subroutines

Translates from one set of characters (Unicode code points) to another.
Characters of `set1` in the input string are replaced with characters of `set2`,
where the first character of `set1` is translated to the first character of
`set2`, and so on. If there are more characters in `set1` than in `set2`, the
last character of `set2` is used to replace all excess characters of `set1`.
Characters in the input string not contained in `set1` are passed through
unchanged.

## Errors

This function requires the input string `input` to be UTF-8 encoded. If it is
not, `fastly.error` will be set to `EUTF8`.

## Example

```vcl
declare local var.in STRING = "Hello, world!";
declare local var.out STRING;

# ROT13
set var.out = utf8.translate(var.in,
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
  "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm");
# var.out is "Uryyb, jbeyq!"

# Remove a set of accents from req.url
set req.url = utf8.translate(req.url, "áäåéëíïóöøúü", "aaaeeiiooouu");
```
