Skip to content

Commit

Permalink
add fix for UTF-8 BOM encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTuxn committed Feb 14, 2023
1 parent 7427ae0 commit 90bf6d7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private String prepareFileString (String yamlFileString) {
private Reader getConfigContent(YamlFile yamlFile) {
if (!yamlFile.getFile().exists()) return new InputStreamReader(IOUtils.toInputStream("", StandardCharsets.UTF_8));

try (BufferedReader reader = new BufferedReader(new FileReader(yamlFile.getFile()))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(yamlFile.getFile().toPath()), StandardCharsets.UTF_8))) {
int commentNum = 0;
int emptySpaceNum = 0;
String addLine;
Expand All @@ -196,6 +196,8 @@ private Reader getConfigContent(YamlFile yamlFile) {

// Convert config file
while ((currentLine = reader.readLine()) != null) {
currentLine = currentLine.replace("\uFEFF", ""); // fix for UTF-8 BOM encoding

// Add comment
if (currentLine.startsWith("#")) {
addLine = (currentLine.replaceFirst("#", "COMMENT_" + commentNum + ":")
Expand Down

0 comments on commit 90bf6d7

Please sign in to comment.