Handle special characters correctly, handle plus signs correctly, and made code more efficient

I fixed a problem I encountered on windows apache/PHP server: Special
characters (like é) in files and folders are not handled correctly.
Running scandir() on a windows system returns files and folder names in
WINDOWS-1252 encoding, which does NOT work when calling `htmlentities()`
over them for these kind of special characters. Therefor the encoding is
converted to UTF-8 which works correctly with `htmlentities()`.

Forgot to add my initial commit:
Also changed `urlencode()` to `rawurlencode()` to handle files/directories containing a plus (+) sign correctly. `urlencode()` changes + to spaces, however it's perfectly possible (on a windows system at least) to have files/folders containing plus signs, these should remain plus signs and not be changed into spaces.

Also shortened the code/made it more efficient: Instead running 2 loops (one for files, one for directories) over the `$files` array, i changed it to one loop and handle the differences for files and directories inside the loop.