There is a text in ascii, you need to change it in UTF-8 encoding with the help of the chardet command. do not tell me how? did not find in documentation

  • It seems that you did not read it at all. Chardet serves to determine the encoding and only. It is impossible to change the encoding using it. - Sergey Gornostaev
  • @SergeyGornostaev what then can be changed? - babyborn
  • one
    Built-in language tools. - Sergey Gornostaev
  • 2
    Any text in ASCII is automatically text in UTF-8 and do not need to change anything - andreymal

1 answer 1

As already mentioned above, the chardet serves to determine the encoding. Strings are encoded and decoded using the appropriate .decode & .encode methods that are standard in python. For example:

import chardet s1 = 'абракадабра' s2 = chardet.detect ( s1 ) [ 'encoding' ] s3 = s1.decode( s2 ).encode( 'utf8' )