Tuesday, 9 October 2007

There Ain't No Such Thing As Plain Text.

Encoding, is always a funny thing when you debug distributed application (also client server architectures). For the simple reason, that you test output from the client, might not look the same from the servers point of view, since there might be differences in the encoding.

So remember to think about, what happens to you request string. remember the following example:

Make a string in any given language:

String testString = "Test string";

to print this to the console, use:

System.out.println(testString) <- println uses a default encoding to print it, the bytes in memory.

When the testString goes through several steps, before it is reached by a server.
First et will be encoded to go on the network (socket), and decoded again by the server. There is therefore 3 different places, that a single debug output, can be different from the what the server actually saves.

The following article describe the very basics of encoding, do you self a favor and read it, or something similar.

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Its easy and very understandable.

No comments: