We use Template Toolkit in a Catalyst app. We configured TT to use UTF-8 and had no problems with it before.

Now I call the substr() method of a string var. Unfortunately it does split the string after *n* bytes instead of *n* chars. If the *n*'th and *(n+1)*'th byte build a unicode char it is split and only the 1st byte is part of substr() result.

**How to fix or workaround that behaviour?**

```
[% string = "fööbär";

string.length; # prints 9

string.substr(0, 5); # prints "föö" (1 ascii + 2x 2 byte unicode)

string.substr(0, 4): # prints "fö?" (1 ascii, 1x 2 byte unicode, 1 unknown char)
%]

```

Until now we had no problems with Unicode chars, neither ones comes from the database nor text in the templates.

**Edit:** This is how I configure the `Catalyst::View::TT` module in my Catalyst app:

```
__PACKAGE__->config(
#   DEBUG => DEBUG_ALL,
    DEFAULT_ENCODING => 'utf-8',
    INCLUDE_PATH => My::App->path_to( 'root', 'templates' ),
    TEMPLATE_EXTENSION => '.tt',
    WRAPPER => "wrapper/default.tt",
    render_die => 1,
);

```