Another day at work (right after holiday too) I encountered this problem with XML and encoding. As I have a lack of knowledge on this topic, it took me a while to figure this out (asking around for help) and it turned out to be a very valuable lesson for me.
You see the XML file that created the error contains some special XML characters. Now what I mean by 'special characters' are one of these (see link): Special Characters and Symbols, e.g. ™, • or √.
The 'actual' symbols you see are in UTF-8 format. However XML may be stored as Latin-1 (ISO-8859-1) encoded. Now because Latin-1 is only 8-bit long so it can only represent characters that is not bigger than the 255 range. On the other hand, UTF-8 can represent up to 8 bytes of data. So it is obvious that some characters in UTF-8 will not be able to be directly converted into Latin-1. In these cases, the ampersand encoded version may be used instead to represent the same character in Latin-1, e.g. ™ • √. This is why it would be important to ensure the 'encoding' you listed in your XML file matches the same encoding the actual file is saved in.
Now the actual problem I was experiencing is I believe someting called HTML purifier. See this very very useful web page which tells you all about this (and gives a good explainations in XML encoding)! You see I was trying to write some Java classes to remove some unwanted node from an XML file's DOM tree. However everytime when I pass in an XML file with 'special characters', it always come back out with a question mark ('?'). The problem was because I got fooled by the encoding that was listed in the xml file and also with the unexpected kindness of Java to try to help me by purifying the XML file.
The problem was resolved by understanding how Java and XML works. Most importantly to understand that the encoding in an XML file is not just purefly for the sake of meta-data, but it is very important in determining which encoding / decoding to use when writing Java classes to process the XML file.
Additional ref: Processing XML with Java
A blog on stuffs that LemonTz has observed and discovered while walking along its journey in life.
Wednesday, 30 December 2009
Tuesday, 29 December 2009
Windows XP Folder Icons Gone BLACK!!!
Prologue: Yes! I was once again on my annual holiday, hence the whole Nov has a result of '0'! So here's me trying to to squeeze in a few more posts before the 2009 year ends! : O
So it was last day before I left work for holiday, not sure what I did that caused it (promised I didn't install any viruses and I never go on dodgy websites!!!). In fact I think it was after remote desktop-ing to my own computer from one of my work mate's computer. When I went back to my computer and logged in, suddenly all the 'folder' icons when I open up Windows Explorer has turned BLACK!!! Seriously!!! The folder icon went BLACK....no cream yellow coloured folder at all..just purely BLACK with the shape of a folder! @.@ I seriously thought I got a virus attack or something. Ran a virus scan nothing showed up and computer is running at the same speed as before and no creepy stuffs popping out!
So it was after I was back from holiday....I got too 'annoyed' by the black looking folders. Not only is it ugly but 'freaky' looking (imagining opening up your system root folder and all you see are a list of BLACK folders!!!)
I did a Google search and SUPER THANKS to this post I was able to fix the problem and all the normal 'creamy yellow' looking folder icons came back alive! : D What happened (I believe) was that Windows actually cache your Windows icons. So somehow after I log back into my machine the cache file must've gone corrupted / munted such that all my folder icons went 'burnt'! The resolution is just to delete the 'IconCache.db' from your "Documents and Settings\[username]\Local Settings\Application Data" directory and your icons will be revived! : D
So it was last day before I left work for holiday, not sure what I did that caused it (promised I didn't install any viruses and I never go on dodgy websites!!!). In fact I think it was after remote desktop-ing to my own computer from one of my work mate's computer. When I went back to my computer and logged in, suddenly all the 'folder' icons when I open up Windows Explorer has turned BLACK!!! Seriously!!! The folder icon went BLACK....no cream yellow coloured folder at all..just purely BLACK with the shape of a folder! @.@ I seriously thought I got a virus attack or something. Ran a virus scan nothing showed up and computer is running at the same speed as before and no creepy stuffs popping out!
So it was after I was back from holiday....I got too 'annoyed' by the black looking folders. Not only is it ugly but 'freaky' looking (imagining opening up your system root folder and all you see are a list of BLACK folders!!!)
I did a Google search and SUPER THANKS to this post I was able to fix the problem and all the normal 'creamy yellow' looking folder icons came back alive! : D What happened (I believe) was that Windows actually cache your Windows icons. So somehow after I log back into my machine the cache file must've gone corrupted / munted such that all my folder icons went 'burnt'! The resolution is just to delete the 'IconCache.db' from your "Documents and Settings\[username]\Local Settings\Application Data" directory and your icons will be revived! : D
Tuesday, 20 October 2009
How to get directory size in Unix shell?
It turns out that finding the size of a directory via shell / command line on a Unix based machine is not 'that' straight forward. Thanks to Dr. Google again...I was able to find the solution (by some kind person who posted the solution on their blog!).
The '-h' makes du return something human readable
Very useful indeed! : D
Ref: http://stevejamesson.com/2008/06/18/unix-get-full-size-of-directory-folder
du -sh dir_nameThe '-s' tells du to only return entries only from the specified directory
The '-h' makes du return something human readable
Very useful indeed! : D
Ref: http://stevejamesson.com/2008/06/18/unix-get-full-size-of-directory-folder
Subscribe to:
Posts (Atom)