import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.input.BOMInputStream;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
Reader reader = null;
try {
- reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
+ reader = new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(file)), encoding));
return new HighlightingRenderer().render(reader, tokenizers);
} catch (Exception e) {
throw new IllegalStateException("Unable to read source file for colorization", e);
private static final Logger LOG = LoggerFactory.getLogger(HighlightingCodeBuilder.class);
- private static final char BOM = '\uFEFF';
-
private SyntaxHighlightingDataBuilder highlightingBuilder = new SyntaxHighlightingDataBuilder();
private int currentOffset = 0;
private static final Pattern START_TAG_PATTERN = Pattern.compile("<span class=\"(.+)\">");
@Override
public Appendable append(char c) {
- if (c != BOM) {
- currentOffset++;
- }
+ currentOffset++;
return this;
}