Very beginner question. While trying to run the script written in LP3THW Ex.23, PowerShell isn't displaying foreign characters. I'm assuming it has to do with UTF16 / UTF8 encoding but I can't figure it out from other posts on stack overflow.
Here is the script:
import sys
script, input_encoding, error = sys.argv
def main(language_file, encoding, errors):
line = language_file.readline()
if line:
print_line(line, encoding, errors)
return main(language_file, encoding, errors)
def print_line(line, encoding, errors):
next_lang = line.strip()
raw_bytes = next_lang.encode(encoding, errors=errors)
cooked_string = raw_bytes.decode(encoding, errors=errors)
print(raw_bytes, "<===>", cooked_string)
languages = open("languages.txt", encoding="utf-8")
main(languages, input_encoding, error)
The text file contents (Languages.txt) can be seen here: https://learnpythonthehardway.org/python3/languages.txt
Image of PowerShell terminal when running script:
Links of other posts which make me even more confused: