EX23 - Can't run, very confused

So far I have gotten to ex23 without much trouble. I have read the issues listed surrounding unicode not working, but I think I am missing something else. I cannot even get it to run and pump out question marks or the boxes. I have searched my code backwards from bottom to top looking for typos or syntax errors. I have read numerous pages on how unicode errors and “continuation byte” errors. I sent an email to the contact email when I purchased this product, but I’m really hoping someone is able to help out.
Thanks.

1% solution
I found this site (https://stackoverflow.com/questions/12468179/unicodedecodeerror-utf8-codec-cant-decode-byte-0x9c) it talked about a number of things I didn’t understand but saw that people were swapping “UTF-8” with “latin-1”. When I do this, the program does run. Is it my incompetence? Is this something with my computer? I am racking my brain trying to understand why I cannot get this to work correctly.

NOT using the latin-1 for utf-8 "fix"

What I type in Powershell:
python ex23.py utf-8 strict

What my ex23.py looks like:

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)

Error Output:
PS C:\Python\Learn> python test23.py utf-8 strict
Traceback (most recent call last):
File “test23.py”, line 23, in
main(languages, input_encoding, error)
File “test23.py”, line 6, in main
line = language_file.readline()
File “C:\Users\Levi\AppData\Local\Programs\Python\Python36\lib\codecs.py”, line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode bytes in position 11-12: invalid continuation byte
PS C:\Python\Learn>

OMG… so i just found this under “suggested topics” EX23 LPTHW ex23 not working

I right click saved the file as was suggested and it now works… Why is this? The reason provided was because the individual there was a non english default language computer. I had 0% faith it would work as, my computer is one obtained in America, and I live in in America. So why did this fix my issue?

I have only had one other issue since starting this program. I cannot get ‘Pydoc’ to work. Could that be related to this default language issue?

Thanks to anyone who reads this.

I thought I fixed that file so it would download rather than save in your language format. Can you give me the exactly link you used to get it? Maybe I missed a link.

And, it doesn’t matter where you bought your computer but rather how you set the native language. What’s your native language?

Apologies busy week at work… :confused: Thanks for the response.

Umm the link was https://learnpythonthehardway.org/python3/languages.txt from page 23 of the Learn Python 3 the hard way PDF

My native language is English, American not British. Is that something I need to change in my PC?

Also, when I open it its a URL that just shows all the words. I decided to highlight it all then paste it into notepad. I was able to right click and do “save as” though.

Not sure if thats the situation you thought was there or not.