D
Dave Angel
Nope, the ASCII subset is identical. It's the ones between 80 and ff¯º¿Â said:For example an 'a' char in iso-8859-1 is stored different than an 'a'
char in iso-8859-7 and an 'a' char of utf-8 ?
that differ, and of course not all of those. Further, some of the codes
that are one byte in 8859 are two bytes in utf-8.
You *could* just decide that you're going to hardwire the assumption
that you'll be dealing with a single character set that does fit in 8
bits, and most of this complexity goes away. But if you do that, do
*NOT* use utf-8.
But if you do want to be able to handle more than 256 characters, or
more than one encoding, read on.
Many people confuse encoding and decoding. A unicode character is an
abstraction which represents a raw character. For convenience, the first
128 code points map directly onto the 7 bit encoding called ASCII. But
before Unicode there were several other extensions to 256, which were
incompatible with each other. For example, a byte which might be a
European character in one such encoding might be a kata-kana character
in another one. Each encoding was 8 bits, but it was difficult for a
single program to handle more than one such encoding.
So along comes unicode, which is typically implemented in 16 or 32 bit
cells. And it has an 8 bit encoding called utf-8 which uses one byte for
the first 192 characters (I think), and two bytes for some more, and
three bytes beyond that.
You encode unicode to utf-8, or to 8859, or to ...
You decode utf-8 or 8859, or cp1252 , or ... to unicode
Then you'd better hope you never manipulate those literals. For example,I use Python 2.4 and never used the u prefix.
the second character of some international characters expressed in utf8
may be a percent symbol, which would mess up string formatting.
A string is an object containing characters. A string literal is one ofi Still don't understand the difference between a 'string' and a
'string literal'
the ways you create such an object. When you create it that way, you
need to make sure the compiler knows the correct encoding, by using the
encoding: line at beginning of file.
The web server wraps a few characters before and after your html stream,If i save a file as iso-8859-1 but in some of my variabels i use greek
characters instead of telling the browser to change encoding and save
the file as utf-8 i can just use the u prefix like your examples to
save the variables as iso-8859-1 ?
http cliens send request to http server(apache) , apache call python
interpreter python call mysql to handle SQL queries right?
My question is what is the difference of the python's script output
and the web server's output to the http client?
but it shouldn't touch the stream itself.
No, the first is an 8 bit copy of whatever bytes your editor happened toWho is producing the html code? the python output or the apache web
server after it receive the python's output?
see above.
I'm not sure whatr exaclty the do just yet.
For example if i say mymessage = "καλημÎÏα" and the i say mymessage = u"καλημÎÏα" then the 1st one is a greek encoding variable while the
2nd its a utf-8 one?
save. The second is unicode, which may be either 16 or 32 bits per
character, depending on OS platform. Neither is utf-8.
mymessage = u"καλημÎÏα"So one script can be in some encoding and some parts of the script
like th2 2nd varible can be in another?
creates an object that is *not* encoded. Encoding is taking the unicode
stream and representing it as a stream of bytes, which may or may have
more bytes than the original has characters.
I personally haven't done any cookie code. If I were debugging this, I'd============================
Also can you please help me in my cookie problem as to why only the
else block executed each time and never the if?
here is the code:
Code:if os.environ.get('HTTP_COOKIE') and cookie.has_key('visitor') = 'nikos': #if visitor cookie exist print "ΑΠΟ ΤΗΠΕΠΟΜΕÎΗ ΕΠΙΣΚΕΨΗ ΣΟΥ ΘΑ ΣΕ ΥΠΟΛΟΓΙΖΩ ΩΣ ΕΠΙΣΚΕΠΤΗ ΑΥΞΑÎΟÎΤΑΣ ΤΟΠΜΕΤΡΗΤΗ!" cookie['visitor'] = 'nikos', time() - 1 ) #this cookie will expire now else: print "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΠΣΕ ΕΙΔΑ, ΔΕΠΣΕ ΞΕΡΩ, ΔΕΠΣΕ ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΠΟ ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!" cookie['visitor'] = 'nikos', time() + 60*60*24*365 ) #this cookie will expire in an year
How do i check if the cookie is set and why if set never gets unset?!
factor out the multiple parts of that if statement, and find out which
one isn't true. From here I can't guess.
DaveA