Answer the question
In order to leave comments, you need to log in
How to read (work with streams) only Russian words from a file?
For text parsing, I need to read only Russian words. How to "configure" a stream, for example, stringstream, so that, for example, it reads only Russian words or only English. .imbue is not working...
Answer the question
In order to leave comments, you need to log in
stringstream is just a class that is described in the language specification with some functionality. If the developer of a certain compiler for some OS considers that it is necessary to add support for some non-ASCII language, then this will already be a crutch and non-cross-platform code. So you need to either look for such things under the platform, or hope that something like that is standardized in C11-14.
No way. Come up with the predicate "this is a Russian word" and filter the stream.
The predicate itself - either "contains only Russian letters", or "is in the dictionary".
What do you mean by "imbue is not working".
How do you read words?
If you use the >> operator, then in principle it is enough to change the ctype facet in the locale used to your own, where Latin letters will be considered whitespace characters (and you may have to force Russian letters to be understood as letters) and the usual extraction operator from the stream will read only sequences of Russian letters .
True, you need to be careful with encodings.
Program example:
ideone.com/Es7fs1
coliru.stacked-crooked.com/a/8c32c9870ca5aafc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question