See last post or RTFM

The whole day I was working on figuring out the question I needed to ask to find out what my problem was or wether I had a problem. I finally found my question and got my answer.

Did you ever notice that all the good ideas occur to you while either trying to go to sleep, taking a hot bath or on your way home from work? Well I regularly notice, but still noone will let me go to sleep more often or soak in a hot tub all day. Going home from work is also a very time-limited activity if you live 10 minutes from your workplace (by bike! going slow!).

Anyhow I might have come to my solution much faster had I thought of the (newfound?) possibility to see the source of the java class libraries in eclipse (I am really sure it wasn’t always that way) or alternatively read the javadoc of the Socket class twice (see title). This way I spent half of the day thinking up a question … but I learned something and at least now I am sure that Sockets work exactly that way.

The question? Well I asked “Is it possible to get neither a connect nor a connection refused?” Answer: “Yes of course.” Rather trivial, I know but I really do not want to explain the reasons behind the question. Well I am really like a newborn networking genius. Who expects a newborn to talk tcp when it’s a week old? The questions will become less trivial soon, I promise 😉

Golden Rules: Read twice!

I should have spent more time on the documentation for java 5.0 because I could have saved myself the trouble of implementing stuff the old way: Enums

Constant-specific methods are reasonably sophisticated, and many programmers will never need to use them, but it is nice to know that they are there if you need them.

“reasonably sophisticated” sounds good, doesn’t it? I like the concept very much. So I guess I am prone to over-use it. I’ll be careful, thanks for the hint 😉

Do you trust your doctor?

Right now I can’t shake the feeling that they are all greedy little monkeys just out to get my money. (and nowadays preferably my money as opposed to my insurance’s money!)

By the way I would really like to blame someone for all this …

Right now I am compensating by eating a tasty piece of ‘winter’ cake from the bakery.

Mozilla.org?

Something I missed? Mozilla.org is absolutely slow today. Well it wasn’t this morning? DOS? Too many fans? Something else? Hey, I want a new thunderbird ….Want want want ….. do you hear my consumerist screaming?

update: the moment I wrote this article the site is back? weird? no just the same as the trucks pulling left whenever I get scared they might …. telepathy I say!

related: /opt rules!!!

Scandalous!

The WoW preorder package for Europe is sold out at amazon.de …. so the pre-orders for the pre-orders are sold out. And the US has launched and people are waiting 2 hours to go online on one of the 40+ servers (8x as many as diablo2) … You know I’ll be mad if I don’t get my collector’s edition. Want collector’s edition. I want one. All the hype is sick. Well all the other people hyping it are sick. Not me. No.

Locales + Encodings: The Final Chapter

Hopefully this has been the last time I had such trouble with encodings. I think I finally managed to understand what caused all the troubles and how to avoid them in the future.

  1. dpkg-reconfigure locales (mine are 75-78, notably de_DE.utf-8)
  2. export LANG=de_DE.utf-8
  3. “file” actually checks iso/utf-8 files correctly (otherwise use hexdumps and encoding manpages!)
  4. Read in java files with encoding set correctly! (use iconv to convert strange input files to something java understands)
  5. Write out java files with encoding set correctly, yes force it! Between 4 and 5 you can have full control over conversion of encodings
  6. Yes there are java io classes that let you set encoding
  7. Configure database driver correctly. jdbc.encoding=utf-8 (it does not matter database doesn’t know utf-8)
  8. Use the same encoding whereever you can!!!
  9. Configure your shell+terminalprogram to display encoding correctly (see 1)
  10. Remember: utf-8 uses multibyte characters that’s the strange button in your terminal program
  11. Don’t forget to configure log4j to write utf-8 encoded files (really helps with debugging)
  12. Set your eclipse (or netbeans or what) to utf-8 encoding
  13. Configure your ant file so that your source-code is read as utf-8 in case you have utf-8 Strings in your classes …
  14. Don’t forget to write your encoding inside your xml header in your xml files.
  15. If you don’ like utf-8 substitute with your favorite encoding.
  16. MOST IMPORTANT: use the same encoding everywhere for your stuff. If something fails later, you know it’s not your stuff.
  17. Sometimes check your stuff on a different machine without any locales set just so you know you managed to program your java independent from your local settings!
  18. Aehm: without thorough tests you are doomed! And listen when your
    tests scream: ERROR!
  19. Believe me when I say: ISO is not enough!

That’s the stuff I learned from all my troubles with encodings. Any questions? I think I may be able to answer a few at least where it concerns java and shell configuration 😉

Reproduce

A bug you cannot a reproduce is a bug you cannot safely fix!

That is what I learned for today.