LINUX.ORG.RU
решено ФорумAdmin

bash cgi translit

 , , , ,


0

2

Нужно сделать так, чтобы cgi-скрипт на bash переводил синволы из русского в транслит. Вот тестовый скрипт:

#!/bin/bash

echo "Content-Type: text/html"
echo ""

echo "Тест"|./trans.sed
#export

При попытке провести транслитизацию, в логах apache появляются ошибки:

old:/var/www# tail /var/log/apache/error.log
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
printf: write error: Broken pipe
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
printf: write error: Broken pipe
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
/bin/sed: file ./trans.sed line 2: strings for `y' command are different lengths
old:/var/www#

Сам транслитизатор:

old:/var/www# cat ./trans.sed
#!/bin/sed -f
y/абвгдеёжзийклмнопрстуфхцчшыэюя/abvgdeöžzijklmnoprstufhcčšyeüä/
s/щ/šč/g
s/ъ/'/g
s/ь/'/g
y/АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЫЭЮЯ/ABVGDEÖŽZIJKLMNOPRSTUFHCČŠYEÜÄ/
s/Щ/Šč/g
s/Ъ/'/g
s/Ь/'/g

в чём ошибка

★★★★★

echo «Тест» | env LANG=en_US.UTF-8 ./trans.sed

Black_Shadow ★★★★★
()

sed должен знать, что локаль юникодная.

Black_Shadow ★★★★★
()

в чём ошибка

синволы

ashot ★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.