# How can I use unix tools with Cyrillic text?

I lately began refining Cyrillic message, and also it is been actually hard.

I could not get my Python manuscripts to collaborate with it in all. And also I attempted.

PHP functioned well, yet I do not recognize PHP. I simply took care of to hack a couple of points with each other, and also I still do not really feel comfy in it. (It might come to be a little an essential, however, as it is confirmed all of a sudden valuable.)

Certainly, grep runs out the inquiry.

Or is it?

That is what this inquiry has to do with.

I intended to do this:

[email protected]:~/\$ grep '\w\{4\}' cyrillicstuff


and also showed up vacant handed.

Yet exists a means I can have returned all words 4 personalities or better, considered that they are done in Cyrillic, making use of excellent 'ol grep??

3
2022-06-07 14:34:31
Source Share

I think you require to make use of the unicode - based personality courses rather. The place - mindful class for word personalities is [:alnum:] and also this is made use of inside personality class, so the command would certainly be

grep '[[:alnum:]]\{4\}' cyrillicstuff


and also see to it your place is readied to the inscribing the documents is in fact in. You can get in touch with locale command and also seek what value it offers for LC_CTYPE group.

This syntax is sustained by all devices that make use of POSIX standard or extensive normal expressions like sed, awk etc as well as additionally by perl and also "perl suitable normal expressions" made use of by python and also php. The perl and also "perl suitable normal expressions" have one added syntax \pX and also \p{xxx}, where X or xxx is a unicode group name, so \pL coincides as [:alpha:] and also \p{Uppercase} need to coincide as [:upper:]. All unicode groups need to be useful.

Advertisement python. Python is flawlessly unicode mindful also. In python 3 it need to function out of package, opening up files in place inscribing appears to be default there (yet I simply looked it up, not examined). Nonetheless in python 2, you need to define the encodings there by hand. They need to be set for stdin, stdout and also stderr, but also for all various other files you need to make use of the codecs.open function and also define the inscribing you obtain from locale.getpreferredencoding() and also you need to boot up places like in C with locale.setlocale(locale.LC_ALL, '').

4
2022-06-07 14:53:58
Source