• Accentuated characters in log files are not rendered correctly

    By Lionel HERVIER 1 decade ago

    I'm using a french version of Domino Server, and accentuated characters are used in error messages. But when reading the error log files from XPages Log File Reader, all accentuated characters are broken.

    My Domino Server is on a Windows Server that is using ISO-8859-1 as default character encoding, but the log files are all encoded using UTF-8.

    So the solution is pretty trivial. I just updated the "readFileFast" method of the "Reader" java design element. In bold, you will find my updates. Of course, you will have to include the corresponding imports too.

    public String readFileFast(String filename, String filter) {
            StringBuilder result = new StringBuilder();
            debug.info( "Reading from file: " + filename + " (filter: "+filter+")");
            File file = new File(filename);
            InputStream fileIn;
            java.io.Reader fileReader;
            try {
                fileIn = new FileInputStream(file);
                fileReader = new InputStreamReader(fileIn, "UTF-8");
                BufferedReader reader = new BufferedReader(fileReader);

                ...
     

    This way, the code is no longer relying on the platform's default encoding, but is forcing the use of UTF-8, and so, accentuated characters are rendered correctly.