the corner office

a blog, by Colin Pretorius

« It's the little things... | Main | Font Hell »

# Cross platform?

Java might be WORA, but it doesn't necessarily follow from RA that one's code will work everywhere. One of my pet Eclipse RCP projects is a simple budgeting tool, and right now all it does is takes all of our downloaded bank statements and dollies them up a bit so we can browse our statements without having to go online.

I soon noticed two oddities when running the app in Gnome as opposed to Windows.

First, all the £ symbols in statement description fields were broken. Doh, I was using a FileReader to open the file. FileReaders just inherit the platform's default character encoding, which meant that on Linux, the default charset is UTF-8. The downloaded .csv files aren't UTF-8, they're ISO-8859-1 or whatever CP equivalent Windows uses. How often do Java developers take the time to think about and specify a character set when opening a file? Not often in my case, until tonight. How often do you even know what character set you're going to have to deal with? To work around the problem I had to subject myself to Java I/O constructor hell:

BufferedReader reader = new BufferedReader( new InputStreamReader( new FileInputStream(fileName), "ISO-8859-1"));

Second, I use JFace's FormToolkit to create web-style forms. I noticed that on Gnome, all form fields were missing their borders. Why? Turns out that internally, FormToolkit decides how to specify the border based on the current operating system, and for some reason, borders aren't set by default for Gnome. I'm sure there was a reason for this some time in the past, but this seems a bit broken to me, now. To fix it, I had to explicitly set a border style for the toolkit, and I'll have to remember to do it for every form I create down the line.

And hope that whatever new work I do, doesn't look too shitty on Windows.

File under: java : {2007.08.06 - 00:13}

Add a comment

Your name (mandatory):

Your email:
Your email address is not displayed
Your home page:

Comment (sorry, no HTML):

Remember details?
Yes No

meta

-home-
about
contact
disclaimer
articles
code
link blog

style: [?]
[plain.dark.blue]

Categories

java
linux
music
notes/domino
personal
politiek
studies
techie
thee_blog
world

RSS Feeds

rssfeed all posts
rssfeed all cmts
rssfeed tech posts
rssfeed tech cmts

Archives

2009.01
2008.12
2008.11
2008.10
2008.09
2008.08
2008.07
2008.06
2008.05
2008.04
2008.03
2008.02
2008.01
2007.12
2007.11
2007.10
2007.09
2007.08
2007.07
2007.06
2007.05
2007.04
2007.03
2007.02
2007.01
2006.12
2006.11
2006.10
2006.09
2006.08
2006.07
2006.06
2006.05
2006.04
2006.03
2006.02
2006.01
2005.12
2005.11
2005.10
2005.09
2005.08
2005.07
2005.06
2005.05
2005.04
2005.03
2005.02
2005.01
2004.12
2004.11
2004.10
2004.09
2004.08
2004.07
2004.06
2004.05
2004.04
2004.03
2004.02
2004.01
2003.12
2003.11
2003.10
2003.09
2003.08
2003.07
2003.06

© Colin Pretorius