[Chicago] Fwd: Message from contact form: Code for recognizing UTF-8 encoded inputt

Robert Dean robertbdean at gmail.com
Wed Apr 9 22:39:59 CEST 2014


This is a very embarrassing "baby" Python question.  But a Python coding
friend of mine in AZ won't be able for consulting until over a month from

To summarize the garbled message below,  would appreciate knowing
how to modify the attached testword1.py code so that it can both recognize
input unicode characters  a n d  output them correctly in a UTF-8 encoded
file.  As it stands:  n o  Cyrillic characters are recognized, only some
characters are, and Latin-1 accented characters are mostly (but not  a l l)

Bob Dean

robertBdean at gmail.com

---------- Forwarded message ----------
From: Cezar Jenkins <emperorcezar at gmail.com>
Date: Wed, Apr 9, 2014 at 9:25 AM
Subject: Re: Message from contact form: Code for recognizing UTF-8 encoded
To: robertbdean at gmail.com
Cc: brianhray at gmail.com


The contact form only goes to a few Chipy organizers. To answer your
question, you’ll probably want to post to our mailing list. You can find a
link to it on our homepage.


Cezar Jenkins

From: donotreply at chipy.org donotreply at chipy.org
Reply: robertbdean at gmail.com robertbdean at gmail.com
Date: April 9, 2014 at 12:39:02 AM
To: emperorcezar at gmail.com emperorcezar at gmail.com, brianhray at gmail.com
brianhray at gmail.com
Subject:  Message from contact form: Code for recognizing UTF-8 encoded

Message from the contact form
Sender: Robert Dean (robertbdean at gmail.com)
The message follows.


A friend of mine has been writing some Python code for me to
"massage" output files from a stat. program we're
maintaining. The issue is what lines to add to several Python programs so
that they blow don't up when encountering unicode characters. I'm
aware of the pieces of the required code to specify that an input file is
UTF-8 encoded. B u t , I'm not a Python programmer myself. And my
friend won't be available to help me until mid-May at the soonest.
Could someone contact about a solution? THANKS. Bob Dean, Chicago

message sent with envelope - a contact form app for Django
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20140409/fecd8d83/attachment.html>
-------------- next part --------------
#! /usr/bin/env python3

# Program Name: "testword2.py"

# This program tests some imput string questions
# and tries to write the input to a file.

#  Python Programmer: Ludwig von Wittelsbach
#  Version date:  090414

import os, sys, string, math, re, shutil, codecs

f= open('testfile.txt', 'w', encoding='utf-8')

inword = input("\nEnter the word to test:  ")

if inword == "":
	print("\nYou just hit return; not a word\n")
	print("\nYour word was "+inword+"\n")

endit = input("\nType enter to exit program")

More information about the Chicago mailing list