Loop comes a huge number of lines

Most come in normal encoding

But in the form of a caveat,

In order for this line to take on a normal look, you need:

name = title.decode('utf-8').encode('cp1251') 

I do such actions with a string of this type - and it becomes normal. The problem is that you need to somehow determine in the loop whether it is the type you want or not ... If you do such actions with each line, then the majority (which were normal) will become scribbles ...

    1 answer 1

     try: win_name = unicode(title.encode('cp1251')) #если title нормального вида, эта строка вызовет исключение name = title.decode('utf-8').encode('cp1251') #если исключения нет, кодируем except UnicodeDecodeError: #если исключение есть - оставляем name = title except UnicodeEncodeError: name = title