Add some more logging and test code for debugging the charset issue