Forced encoding of text to UTF-8

This commit is contained in:
Maruno17
2021-12-20 21:46:29 +00:00
parent 3c85c3fe55
commit dfb3a51815
3 changed files with 9 additions and 1 deletions

View File

@@ -101,6 +101,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
if !line[/^\#/] && !line[/^\s*$/]
line = prepline(line)
if line[/^\s*\[\s*(.*)\s*\]\s*$/] # Of the format: [something]
@@ -159,6 +160,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
if !line[/^\#/] && !line[/^\s*$/]
if line[/^\s*\[\s*(.+?)\s*\]\s*$/]
yield lastsection, sectionname if havesection
@@ -185,6 +187,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
yield line, lineno if !line[/^\#/] && !line[/^\s*$/]
lineno += 1
}
@@ -199,6 +202,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
if !line[/^\#/] && !line[/^\s*$/]
FileLineData.setLine(line, lineno)
yield line, lineno
@@ -215,6 +219,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
line = prepline(line)
yield line, lineno if !line[/^\#/] && !line[/^\s*$/]
lineno += 1
@@ -230,6 +235,7 @@ module Compiler
if lineno == 1 && line[0].ord == 0xEF && line[1].ord == 0xBB && line[2].ord == 0xBF
line = line[3, line.length - 3]
end
line.force_encoding(Encoding::UTF_8)
line = prepline(line)
if !line[/^\#/] && !line[/^\s*$/]
FileLineData.setLine(line, lineno)