see whatever…

jump to menu

November 12, 2006

IE and apos character entity

Filed under: Markup,Web,XML — see @ 8:08 pm

I never thought about the character entity references too much. For XML I assumed at least the 5 predefined ones for character & <> ” and ‘. Naively I assumed this for HTML as well (plus the usual other ones used for years like entities for german umlauts etc).

But it seems I was wrong. ' which is the character entity for ‘ is only defined for XML but not HTML. It is used so seldom that it never struck me until I did some tests on IE 7 today. On my GIVE-A-WORD feature on my personal site I needed to escape ‘ as it is used in Javascript parts in element attributes which use ” as delimiter. So I had escaped ‘ with &apos; for quite some time now. It seems though that IE does not know this char ref and simple outputs the complete string… serving the exact same thing as application/xml does tickle IE into XML mode which then knows the ref. Really strange and unnecessary too. Solution would be to use a numeric reference, might do that or simple ignore this case which will happen rather seldom anyway.
For more details see e.g. http://lachy.id.au/log/2005/10/page/2/.

UPDATE:

Not easy to write this post in WordPress BTW, the HTML editor keeps changing the entities or does weird things with them…

August 19, 2006

Newlines

Filed under: Markup,Programming,Unicode — see @ 1:57 pm

Interesting article at O’Reilly “Understanding Newlines” which is written for Perl but holds true for Python, too. I knew about possible problems but did not run into any problems with newlines yet. But the actual details I did not know completely and so understand why Subversion complains about a mix of newline characters in files I have checked in (which probably was coworkers and me use different editors with even different option settings). Now I also understand what textmode opening of files actually does. This may seem ignorant but until now I almost always worked with textfiles anyway which do not cause problems when using the default textmode filemode of Python and other languages…

Anyway, interesting article, also because some infos about unicode newline characters.

July 13, 2006

Python and Excel

Filed under: Data,Markup,Python — see @ 8:58 pm

I guess there are quite a few tools to process Excel with Python but I found (and used) the following which are easy to use and were sufficient at least for my humble needs…

To just read an Excel spreadsheet a recipe in the Python Cookbook is very useful.

To actually produce sheets the pyexcelerator at SourceForge is very nice. Helpful usage instruction may be found here.

Another even simpler (no lib needed) possibility is to actually produce a simple HTML file with just an HTML table in it and save it as *.xls. Anything like simple “print” statements (taking care of proper escaping of < and & for example) or (preferably) any XML producing library should do fine. Just open this in Excel and even stuff like coloring (with td/@bgcolor), aligning (td/@align) or row/colspan just works. Unfortunately this was not my idea but that of a colleaque but very easy to use but very powerful too.
Another of those entries to remind myself ;)

Powered by WordPress