A
A
Alexander Semenenko2016-09-15 15:42:30
Character encoding
Alexander Semenenko, 2016-09-15 15:42:30

Problems in file name encoding on Ubuntu and Centos, how to solve?

There was a 1C server on Ubuntu14.04, for which a disk was allocated for storing files via NFS.
Server 1C was transferred to Centos7, NFS share was mounted.
Now new files from 1C are added to the NFS share and opened, and old files are not opened from 1C.
The check showed that new files have unreadable names (in the wrong encoding), they open. And the old files have names in utf-8, are read from Centos, but do not open in 1C.
And Ubuntu 14.04 had a locale: LANG=ru_RU.UTF-8 LANGUAGE=ru_RU
And Centos 7 issues a locale: LANG=ru_RU.UTF-8 LANGUAGE=ru_RU
At the same time, files written in Latin open both old and new.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
inquisitor273, 2016-09-16
@inquisitor273

First you need to determine the current encoding of file names, for this you need the enca utility. Here is an example:

$ ls -1
????1.txt
????2.jpg
+BDUESQRR-_+BD4ENAQ4BD0-_+BEQEMAQ5BDs-.bin

View filenames and their encoding:
$ ls -1 | while read i; do echo "$i: $(echo $i | enca -c): $(echo $i | enca -i)"; done
����1.txt: файл1.txt: CP1251
����2.jpg: файл2.jpg: KOI8-U
+BDUESQRR-_+BD4ENAQ4BD0-_+BEQEMAQ5BDs-.bin: ещё_один_файл.bin: UTF-7

So you can recursively change the encoding of names in the current directory:
$ find . | while read i; do convmv --notest -f $(echo $i | enca -i) -t utf8 ./$i; done

V
Vladimir Kuts, 2016-09-15
@fox_12

Convert the file names to the desired encoding
To read in 1C:
convmv -t UTF-8 -f CP1251 somefile Replace CP1251 with
your encoding

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question