php vs python

Duncan Booth duncan.booth at invalid.invalid
Fri May 23 10:15:55 EDT 2008


Michael Fesser <netizen at gmx.de> wrote:

> .oO(Duncan Booth)
> 
>>On those rare occasions when I've helped someone who wanted advice
>>I've found that my Python oriented viewpoint can be quite hard to
>>translate to PHP. For example I'd suggest 'oh you just encode that as
>>utf8' only to be told that there's no easy way to do that (have just
>>Google'd it looks like there is now a way to do that but with a big
>>red warning about it being EXPERIMENTAL and only use at your own
>>risk). 
>>
>>(Looking at the example given for unicode_encode it appears to depend
>>for its working on a global setting which isn't included in the
>>example. I may have misunderstood the example but if I read that
>>correctly its a good example of why PHP doesn't fit my brain.)
> 
> The only little problem is that PHP doesn't have native Unicode
> support yet, which will change with PHP 6. But of course you can still
> use UTF-8 without any trouble, I do it all the time. You just have to
> keep in mind that many string functions still work on bytes, not on
> characters, but this can almost always be solved with the Multibyte
> extension. Apart from that there's no problem with PHP and UTF-8. It's
> also easily possible to convert between various encodings using the
> iconv extension. 
> 
As I remember it the problem was that the data was stored in a database 
in latin-1 but the HTML page had to be in utf-8 (because the rest of the 
server and therefore all the page skins were already in utf-8). In 
python that would be a trivial conversion but I was told that in PHP it 
wasn't. 

Also it was PHP4 and as I understand it updating to a more recent 
version was non-trivial. Of course sometimes updating Python code to a 
newer version is also non-trivial: Zope in particular is very version 
specific but in most cases anything written in pure Python will be 
compatible with more recent versions.

But one small example isn't really the point. It's that the whole way 
Python works seems *to me* to make sense and (mostly) fits together 
cleanly and consistently. YMMV

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list