4

I have utf-8 locale on my computer, and i want to search in KOI8-R encoded files. But i don't have KOI8-R locale installed. And i don't have sudo rights to install this locale.

Is it possible to search with grep in this conditions? Can i do a workaround? Convert those encoded files to UTF-8 on the fly, somehow?

PS: I already read this question: How to use grep/ack with files in arbitrary encoding?

1

As long as you're looking for specific characters (i.e. not using character sets or case-insensitive search), you can make grep look for bytes: convert any non-ASCII character in the regexp to the byte value that represents it in KOI8-R, and invoke grep in the C locale (LC_ALL=C grep …, or just LC_CTYPE=C LC_COLLATE=C grep …) so that it searches for bytes.

You can use iconv -f utf-8 -t koi8-r to convert a string that you type in UTF-8 to KOI8-R even if the KOI8-R locales aren't listed in locale -a.

The fuseflt method also relies on iconv and doesn't need the locale to be built.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.