antal : 32

Using Text::IConv or Unicode::String? Converting UTF8 to ISO-Latin1 in Perl.

For quite a while I’ve been stuck in a project in which I read some some data from a set of XML-files generated from an external program. The data loading smoothly done by XML::Simple, but the fact that the target is a mysql database with ISO-8859-1 (ISO-Latin1) while the XML is encoded in UTF-8 has caused a few problems.

Perl doesn’t AFAIK come with any really good convertion routines with the standard modules, and since I was somewhat familiar with the GNU-projects libiconv it come naturally too look after a perl module that uses it. After a quick search, Text::Iconv was found on CPAN

However I quickly ran into a few problems: Text::Iconv is only as portable as it libiconv – and just having a binary dependency is a hassle when moving between alot of platforms. Text::Iconv also had some of libiconvs strange behaviour and very limited error handling. Sometimes the converted text was streal strange and I has not been very statisfied.

Today I stumbled upon Unicode::String that smoothly convert between utf-8 and differenet charsets. The potential of supported charsets is less than libiconvs – but since it got ISO-Latin1 I am all happy. After a test round I replaced all convertion calls and so far I have not noticed any real performance drain and no problems at all – as of yet.

CPAN <3

The mystery of the Azureus disk cache

I am on the road for a bit – and for the moment I got access to a pretty swift 100/10 fiber connection courtesy of my generous host. Naturally I quickly decided to test how much this could improve my ratio on the favorite bittorrent trackers and I started seeding away …

It wasnt long before the fans on my poor old trusty G4 Powerbook started to go haywire, the temperature monitor said 60C and I decided that something must be done before the poor mac laptop melts. My prefered bt-client is Azureus, but since my home connection is real slow and my desktop hardware is second to none, I really never had any need to do any more advanced tweaking than limiting the upload speed.

At File -> Preferences -> Files -> Torrents -> Performance Options something interesting was found:

  • [ ] ”Enable disk cache”

A cache for a very disk intensive system as Bittorrent sound very reasonable – nothing fishy there. On the other hand, one could easily think that as much cache as possible is good. Right? The setting had a note that to big cache would create memory problems for the JVM. 32 megs below the maximum VM is recommendend and that more than 32 megs of cache would be overkill. Humm. My current VM-max size was 126.62 mb and I got 1024 in total – so I decided to be bold: I put 50 meg for cache and went out for a smoke.

When I came back the temperature monitor showed 55C and the fans was all quiet. I could not hear one single sound from the disk. Much better!

Now I decided to do my homework properly and started to search after the optimal configuration with OS X/Azuarus/1024mb ram – but no luck! Not much to read about the disk cache at all! I found a nice blog entry that mention it, but the azureus wiki simply say ”Important: set it to 32 MB or less!”. Very confusing.

I would be more than happy if someone could enlighten me – for now I will stick with my 50 megs and will keep on searching for more info.

Tio senaste: