# Bad UTF-8 encoding Latin characters with groovy

**URL:** <https://discuss.elastic.co/t/bad-utf-8-encoding-latin-characters-with-groovy/47361>\
**Category:** Logstash\
**Created:** [April 14, 2016, 8:54am UTC](https://discuss.elastic.co/t/bad-utf-8-encoding-latin-characters-with-groovy/47361 "2016-04-14T08:54:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigtn](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bigtn](https://discuss.elastic.co/u/bigtn)\
**Post date:** [April 14, 2016, 8:54am UTC](https://discuss.elastic.co/t/bad-utf-8-encoding-latin-characters-with-groovy/47361/1 "2016-04-14T08:54:14Z")

</div>

hi,

im using groovy to append an array of nested object on elasticsearch from a csv file

when groovy insert the first object there is no encoding problem, otherwise when he append the array with others objects i have list of words poorly encoded.

im using the same config file with logstash-2.2.2 and it works fine !

the problem only with logstash-2.3.0 and logstash-5.0.0.alpha1

```
output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "accounts"
        document_id => "%{id}"
        action => "update"
        script_lang => "groovy"
        script => "ctx._source.id = %{id}; if (ctx._source.containsKey('items')) {ctx._source.items += [a1:'%{a1}',a2:'%{a2}',a3:'%{a3}',a4:'%{a4}'];} else {ctx._source.items = [[a1:'%{a1}',a2:'%{a2}',a3:'%{a3}',a4:'%{a4}']]; }"
        script_type => "inline"
        scripted_upsert => true
        codec => plain {
            charset => "UTF-8"
        }
    }
}

```

cordially

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:02am UTC](https://discuss.elastic.co/t/bad-utf-8-encoding-latin-characters-with-groovy/47361/2 "2017-07-06T05:02:19Z")

</div>

Closed on July 6, 2017, 5:02am UTC


