Re: Dealing with "funny" characters

2007-10-20 Thread Gert-Jan
sophie_newbie schreef:
> Hi, I want to store python text strings that characters like "é" "Č"
> in a mysql varchar text field. Now my problem is that mysql does not
> seem to accept these characters. I'm wondering if there is any way I
> can somehow "encode" these characters to appear as normal characters
> and then "decode" them when I want to get them out of the database
> again?


It seems you'll have to use Unicode in your program rather than 'plain' 
strings.

Before storing an unicode textstring in a database or a file, you must 
encode it using an appropriate encoding/codepage, for example:

outputstring = unicodeobject.encode('utf-8')


This is not an easy subject. But it isn't very hard either. Please 
search the Python documentation using these keywords: Unicode, decoding 
and encoding.


But you should read this first: 
http://www.joelonsoftware.com/articles/Unicode.html
It's an entertaining introduction to the world of codepages and unicode :-)


Regards,
Gert-Jan

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Help on creating a HTML by python

2004-11-29 Thread Gert-Jan den Besten
sepgy writes:
Can anyone help me to use a python to create an HTML photo gallery
generator. When it's finished, it will be able find all the picture
files (i.e. .jpg, .gif. .png files) in any given folder on the
computer, automatically create smaller thumbnails for each image, and
then generate a complete HTML file that displays a clickable image
gallery. When viewed in a web browser, the HTML file will display the
thumbnails in a neatly formatted table, and if you click on one of the
thumbnails the full-size image will appear.
Thanks

Your script is meant to create something like this? 
http://home.hccnet.nl/gj.den.besten/20040822_maasbommel/html/overzicht_01.html

A few months ago I wrote this script to get familiarized with Python. It 
has a few disadvantages:
* It is not written in English (in Dutch actually).
* Written using a procedural/modular programming style.
  No classes are used, so it is not very "Pythonic"
* Written to meet my needs to get pictures published on my website.
* No GUI.

When I get rid of the first two disadvantages, I will publish the 
sourcecodes on my website. It will be GPL'ed.

So far, I tested it on Linux and WinNT and it seems to work fine. It 
uses the "Python Imaging Library" instead of "ImageMagick". Using PIL 
gives it a better performance.

There is another option:
http://info.linspire.com/lphoto/
This is an Open Source application, built using Python. If you can get 
the source, this may be your best choice.

Gert-Jan
--
 Homepage:
   http://www.GJdenBesten.nl
--
http://mail.python.org/mailman/listinfo/python-list