# Using alt key code in logstash

**URL:** <https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094>\
**Category:** Logstash\
**Created:** [August 15, 2020, 11:26am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094 "2020-08-15T11:26:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 15, 2020, 11:26am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/1 "2020-08-15T11:26:53Z")

</div>

Hi all, i am using logstash to write some data into txt file so that my output configuration of logstash is as following:

```
output {
csv {
fields => ["My_Data"]
path => "D:\app_%{year}_%{mounth}_%{day}.txt"
}
  stdout { codec => rubydebug }

}

```

it is note that "My\_Data" is as following which is based on the some other data:

```
mutate {
	add_field => {
		"My_Data" => "%{Com}-%{Ser}-%{year}-%{mounth}-%{day}-%{count}"
	}
}

```

I am using "-" (dash) in order to separate the items. But, our customer tells us that the separator should be "alt0173" which leads to "-". How can i use "alt0173" instead of direct "-" in my script so that convert to dash in output txt?  
Any advise will be so appreciated.  
Regards

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 15, 2020, 12:53pm UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/2 "2020-08-15T12:53:53Z")

</div>

sorry. i think it has been solved just by using alt0173 in script

---

<div class="post-metadata">

**Author:** ![cknz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cknz/32/9640_2.png) [@cknz](https://discuss.elastic.co/u/cknz)\
**Post date:** [August 17, 2020, 12:37am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/3 "2020-08-17T00:37:20Z")

</div>

For reference, in Unicode, this would be U+00AD, although I doubt that the input would be in any Unicode encoding.

You're likely going to want to set the [charset](https://www.elastic.co/guide/en/logstash/current/plugins-codecs-csv.html#plugins-codecs-csv-charset) in your csv input to match your input file. Eg:

```
input{
    file{
        ...
        codec => csv{ charset=>"Windows-1250" }
    }
}

```

Unfortunately Logstash (still) doesn't have a mechanism for expressing Unicode escape sequences in its configuration, but the configuration file is meant to be UTF-8, so you can (as you've experienced) put literal Unicode characters into it.

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 18, 2020, 7:37am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/4 "2020-08-18T07:37:32Z")

</div>

Many thanks for your reply,  
I used ­alt0173 in csv output fields and when open the output on my PC with Notepad++ it works fine and can find alt0173 (-). But when i open this file on another PC, it cannot find alt0173. Any advise will be so appreciated.

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 18, 2020, 7:56am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/5 "2020-08-18T07:56:04Z")

</div>

I checked out put in Notepad++ using Encode in ANSI which is as following:

O1ÂO2Â­2020Â­06Â­23Â­O3Â­4Â­0

where there is Â instead of "-" (alt0173)

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 18, 2020, 8:32am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/6 "2020-08-18T08:32:35Z")

</div>

when i check my config file in notepad++ using Encoding in ANSI , Â exists in output filed:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/f/df551c87b1d5f03c2377f43efe65035d636daa22.png)

when i delete Â, starting logstash face with following error:

```
`> [ERROR][logstash.agent] An exception happened when converging configuration 
{:exception=>RuntimeError, :message=>"Could not fetch the configuration, message: The 
following config files contains non-ascii characters but are not UTF-8 encoded 
 [\"F:/ELK_Windows/logstash-6.6.0/logstash-6.6.0/bin/OB13.conf\"]", :backtrace=>["F:/ELK_Windows/logstash-6.6.0/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:157:in `converge_state_and_update'", "F:/ELK_Windows/logstash-6.6.0/logstash-6.6.0/logstash-core/lib/logstash/agent.rb:101:in `execute'", "F:/ELK_Windows/logstash-6.6.0/logstash-6.6.0/logstash-core/lib/logstash/runner.rb:362:in `block in execute'", "F:/ELK_Windows/logstash-6.6.0/logstash-6.6.0/vendor/bundle/jruby/2.3.0/gems/stud-0.0.23/lib/stud/task.rb:24:in `block in initialize'"]}`
```

---

<div class="post-metadata">

**Author:** ![cknz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cknz/32/9640_2.png) [@cknz](https://discuss.elastic.co/u/cknz)\
**Post date:** [August 19, 2020, 11:16am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/7 "2020-08-19T11:16:16Z")

</div>

That's to be expected; the configuration file is expected to be in UTF-8. Nothing else will do. Logstash can process other encodings, but its configuration file must be UTF-8.

On Windows, you can use the Character Map application (if you can't type the character yourself). You'll want a Unicode font, such as Arial, tick the Advanced box, and in the 'Go to Unicode' box, enter 00AD. You'll find two things:

- Unicode calls this character 'Soft Hyphen'
- It also shows the Windows Alt-Keypad keystroke sequence (Alt+0173)

You can click on the Select the character for the 'Characters to copy' if you want to just copy it into your logstash configuration.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b26edce54f1b1ee69c3af2d9ed235517e761f257.png)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![sahere37](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@sahere37](https://discuss.elastic.co/u/sahere37)\
**Post date:** [August 20, 2020, 7:52am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/8 "2020-08-20T07:52:00Z")

</div>

Many thanks for your reply. I type alt0173 for output field in the logstash config as fields separator, but the problem is in the output txt. txt file separator has been shown as "Â-" instead of "-". my config file is creating a txt file daily which includes some data separated using alt0173. customer is using ANSI encoding and they are seeing output separator as "Â-" instead of "-". how can i handle this issue so that output txt file separator automatically shows alt0173 (-) instead of (Â-).

---

<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:** [September 17, 2020, 7:52am UTC](https://discuss.elastic.co/t/using-alt-key-code-in-logstash/245094/9 "2020-09-17T07:52:05Z")

</div>

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