Q
Q
QQ2016-05-03 01:36:50
bash
QQ, 2016-05-03 01:36:50

Why does Cyrillic in bash scripts behave incorrectly?

Hello.
There is a standard code for entering user information in bash.

#!/bin/bash

read -p 'НАЗВАНИЕ: ' NAME

echo ${NAME}

I type Hello (switch layout and add World ) Hello World , then delete World and write World. As a result, I get:
~# sh read.sh
НАЗВАНИЕ: HelloWorld
HelloМ▒World

Why is that and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2016-05-03
@botaniQQQ

try like this:

#!/bin/bash

read -p "НАЗВАНИЕ: " NAME
echo $NAME | iconv -c -t UTF-8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question