def getString(self):
data = ''
keypress = []
c = self.request.recv(1024) while c == '\b':
self.request.send(' ')
c = self.request.recv(1024)
if len(©) <= 1:
keypress.append(©)
while c != endl:
c = self.request.recv(1024)
if c == endl:
break
elif c == '\b':
self.request.send(' \b')
if (len(keypress) > 0):
keypress.pop()
else:
while c == '\b':
self.request.send(' ')
c = self.request.recv(1024)
keypress.append(©)
else:
keypress.append(©)
for key in keypress:
data += key
else:
data = c
if endl in data:
data = data.strip(endl)
return data
Non-ASCII Symbols causing run error
Page 1 of 15 Replies - 258 Views - Last Post: 02 October 2012 - 07:04 PM
#1
Non-ASCII Symbols causing run error
Posted 02 October 2012 - 06:22 PM
So I got the following code from someone else, but have been trying to figure out whats wrong with it. The thing that is causing the problem is the "©" symbol apparently used to pick up the enter key (hex 0D0A or something). I've searched around a bit but everything is about how to to unicode in a string. The error also told me I could put the line "# -*- coding: utf-8 -*-" in my code to fix it, but it didnt. I am not really that good in python so I am sort of clueless on how to fix something like this. Any ideas?
Replies To: Non-ASCII Symbols causing run error
#2
Re: Non-ASCII Symbols causing run error
Posted 02 October 2012 - 06:29 PM
Add apostrophe's? (')
Yep, most definitely do that. Cake is 0:
>>> '©' '\xb8'
Yep, most definitely do that. Cake is 0:
>>> if cake == 0: ... print 'Jenny' + '©' ... else: ... print 'I haz cake' ... Jenny©
#3
Re: Non-ASCII Symbols causing run error
Posted 02 October 2012 - 06:29 PM
#4
Re: Non-ASCII Symbols causing run error
Posted 02 October 2012 - 06:32 PM
Wait, what did you want to do with that symbol, get the enter key press?
#5
Re: Non-ASCII Symbols causing run error
Posted 02 October 2012 - 06:45 PM
fromTheSprawl, on 02 October 2012 - 04:32 PM, said:
Wait, what did you want to do with that symbol, get the enter key press?
Its some really stupid complicated way of getting data, the previous version of this only captured 1 letter at a time, the enter thing was someones revision so it wouldnt do that, but I think its just overly complicated, but thanks it did work.
#6
Re: Non-ASCII Symbols causing run error
Posted 02 October 2012 - 07:04 PM
Whoa that's neat, glad to know it worked.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|