converting html escape sequences to unicode characters
I have a list of about 2500 html escape sequences (decimal) that I need to convert to utf-8. Stuff like: 비 행 기 로 보 낼 거 에 요 내 면 금 이 얼 마 지 잠 Anyone know what the decimal is representing? It doesn't seem to equate to a unicode codepoint... culley -- http://mail.python.org/mailman/listinfo/python-list
Subprocess and /usr/bin/dialog
I am trying to get the below code to work and can't quite make things happen. This is with Python 2.5.1. Dialog is doing something odd... I have tinkered with different combinations and I can't get the dialog to show properly-- it does show properly directly in the shell. Any hints? import subprocess command = '/usr/bin/dialog --clear --title "title" --menu "text" 20 50 5 "a" "this and that" "c" "3 this and that" "b" "2 this and that" "d" "4 this and that"' proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) #proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) stderr_value = proc.communicate()[0] print stderr_value -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess and /usr/bin/dialog
On Mar 21, 3:59 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-21, harrelson <[EMAIL PROTECTED]> wrote: > > > I am trying to get the below code to work and can't quite make things > > happen. This is with Python 2.5.1. Dialog is doing something odd... > > I have tinkered with different combinations and I can't get the dialog > > to show properly-- it does show properly directly in the shell. Any > > hints? > > > import subprocess > > command = '/usr/bin/dialog --clear --title "title" --menu "text" 20 50 > > 5 "a" "this and that" "c" "3 this and that" "b" "2 this and that" "d" > > "4 this and that"' > > proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, > > stderr=subprocess.STDOUT) > > #proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) > > stderr_value = proc.communicate()[0] > > print stderr_value > > [It would be helpful if you didn't wrap sample code when you > post it.] Sorry I posted through google groups and it wrapped it for me... > dialog displays the widget on stdout. You've connected stdout > to a pipe, so you're not going to see anything displayed unless > you read data from the stdout pipe and write it to the terminal. Reading this tutorial on subprocess: http://blog.doughellmann.com/2007/07/pymotw-subprocess.html led me to believe this was exactly what I was doing. The screen does actually turn blue for a second but it is as if I only get one keystroke and python is back in control... -- http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess and /usr/bin/dialog
>
> [It would be helpful if you didn't wrap sample code when you
> post it.]
>
> dialog displays the widget on stdout. You've connected stdout
> to a pipe, so you're not going to see anything displayed unless
> you read data from the stdout pipe and write it to the terminal.
Also... if I put the dialog call in a one line shell script and
execute it with:
subprocess.call('dialog.sh')
it works properly.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Subprocess and /usr/bin/dialog
Thanks Grant, that does it! I knew it had to be something simple like that and it was frustrating not to be able to find it. I do prefer the tuple. Thanks again. culley -- http://mail.python.org/mailman/listinfo/python-list
encoding ascii data for xml
I have a large amount of data in a postgresql database with the
encoding of SQL_ASCII. Most recent data is UTF-8 but data from
several years ago could be of some unknown other data type. Being
honest with myself, I am not even sure that the most recent data is
always UTF-8-- data is entered on web forms and I wouldn't be
surprised if data of other encodings is slipping in.
Up to the point I have just ignored the problem-- on the web side of
things everything works good enough. But now I am required to stuff
this data into xml datasets and I am, of course, having problems. My
preference would be to force the data into UTF-8 even if it is
ultimately an incorrect encoding translation but this isn't working.
The below code represents my most recent problem:
import xml.dom.minidom
print chr(3).encode('utf-8')
dom = xml.dom.minidom.parseString( "%s" %
chr(3).encode('utf-8') )
chr(3) is the ascii character for "end of line". I would think that
trying to encode this to utf-8 would fail but it doesn't-- I don't get
a failure till we get into xml land and the parser complains. My
question is why doesn't encode() blow up? It seems to me that
encode() shouldn't output anything that parseString() can't handle.
Sorry in advanced if this post is ugly-- it is through the google
groups interface and google mangles the entry sometimes.
--
http://mail.python.org/mailman/listinfo/python-list
