I haven't tried this in either of those language, but did stumble upon this article:
http://www.samspublishing.com/librar...seqNum=64&rl=1

There's some code that I think you are looking for near the bottom. Hope that helps a little.