To give an explanation: when you have:
mystring = 'some string encoded with some codec' myunicode = u'%s' % mystring Since you are telling python that you want a unicode object from a string object, python will try do decode (convert) `mystring` with the default encoding, since you didn't explicit what was the encoding. It happens that on Linux the python default encoding is 'ascii': >>> import sys >>> sys.getdefaultencoding() 'ascii' and if the string has some bytes not recognized by the ascii codec you get an exception. On Windows just check what you have as the default encoding, I am sure you have a different codec - (I don't have windows to test) Ricardo On Wed, May 15, 2013 at 1:10 PM, Yebach <[email protected]> wrote: > Thanx > > I removed the 'u' infront of string and it works > > thanx again > > > On Wednesday, May 15, 2013 11:29:34 AM UTC+2, Ricardo Pedroso wrote: >> >> > Thank you for showing interest in resolving this. I apologize for not >> > answering faster >> > >> > @Massimo - where do I set layout encoding? >> > >> > >> > This is the whole error trace >> >> What you show us was not your traceback, here is your traceback, >> not that hard and concise and just to the point, right? >> >> Traceback (most recent call last): >> File "/usr/local/web2py/gluon/restricted.py", line 205, in restricted >> exec ccode in environment >> File "/usr/local/web2py/applications/iurnik/controllers/user.py", >> line 8, in <module> >> File "/usr/local/web2py/gluon/globals.py", line 173, in <lambda> >> self._caller = lambda f: f() >> File "/usr/local/web2py/applications/iurnik/controllers/user.py", >> line 3, in user >> form = auth() >> File "/usr/local/web2py/gluon/tools.py", line 1161, in __call__ >> return getattr(self,args[0])() >> File "/usr/local/web2py/gluon/tools.py", line 1967, in register >> callback(onaccept,form) >> File "/usr/local/web2py/gluon/tools.py", line 57, in callback >> [action(form) for action in actions] >> File "/usr/local/web2py/applications/iurnik/models/db.py", line 143, >> in <lambda> >> message=u\'Na bazi %s se je kreiral nov uporabnik %s %s z e-mailom >> %s , ki ga je potrebno potrditi\' % (database, form.vars.first_name , >> form.vars.last_name, form.vars.email)) >> UnicodeDecodeError: \'ascii\' codec can\'t decode byte 0xc5 in >> position 0: ordinal not in range(128) >> >> >> I think your problem is in models/db.py in the following line: >> >> message=u'Na bazi %s se je kreiral nov uporabnik %s %s z e-mailom %s >> , ki ga je potrebno potrditi' % (database, form.vars.first_name, >> form.vars.last_name, form.vars.email)) >> >> try to remove the u in front of the string: >> >> message = 'Na bazi ..... >> >> or decode the form vars, ex: >> >> .... % (...., form.vars.first_name.decode('utf-8'), ....) >> >> >> Ricardo > > -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

