# How to change UCS-2 LE to UTF-8

**URL:** <https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181>\
**Category:** Logstash\
**Created:** [April 10, 2019, 9:05am UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181 "2019-04-10T09:05:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterch](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@peterch](https://discuss.elastic.co/u/peterch)\
**Post date:** [April 10, 2019, 9:05am UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181/1 "2019-04-10T09:05:12Z")

</div>

Dear All,

I use filebeat to get a log file to logstash. The log is encoded with UCS-2 LE. I tried to change to UTF-8 but fail. Anyone can help? The following is my logstash config for reference.

> input {  
> beats {  
> port =\> 5047  
> tags =\> "filebeat"  
> codec =\> plain { charset=\>"UTF-8" }  
> }  
> }

Thanks

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 10, 2019, 11:29am UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181/2 "2019-04-10T11:29:42Z")

</div>

The charset on the codec has to match what the encoding on the file is. I am not familiar with the BE/LE distinction in UCS, but the codec should accept charset =\> UCS-2BE. Does that help?

---

<div class="post-metadata">

**Author:** ![peterch](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@peterch](https://discuss.elastic.co/u/peterch)\
**Post date:** [April 11, 2019, 2:25am UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181/3 "2019-04-11T02:25:09Z")

</div>

I will try. I want to know if I want to change to UTF-8, is the configuration correct?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 11, 2019, 12:47pm UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181/4 "2019-04-11T12:47:24Z")

</div>

Internally, it's Java, so the charset will be UTF-16. You can set the codec on the input and output to be whatever you need.

I am guessing that BE/LE is big-endian/little-endian. I do not understand UTF well enough to see why BE/LE is a thing for UCS-4, but not for UCS-2.

---

<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:** [May 9, 2019, 12:47pm UTC](https://discuss.elastic.co/t/how-to-change-ucs-2-le-to-utf-8/176181/5 "2019-05-09T12:47:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
