Skip to content

Commit 5528671

Browse files
authored
Add support for different encodings (#210)
* Add support for different encodings Add an '--encoding' flag to the CLI options to allow setting a custom encoding. When no encoding is passed, attempt to read the encoding from BOM Tread as UTF-8 if all else fails. This uses the encoding_rs_io crate to do this Remove the dyn trait forSourceContainer as it's not required in this case Add integration tests for lib methods
1 parent 862f5e7 commit 5528671

14 files changed

+325
-129
lines changed

.vscode/launch.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"type": "lldb",
910
"request": "launch",
@@ -38,7 +39,7 @@
3839
"kind": "bin"
3940
}
4041
},
41-
"args": ["examples/MainProg.st"],
42+
"args": ["--ir", "examples/encoding.st"],
4243
"cwd": "${workspaceFolder}"
4344
},
4445
{

Cargo.lock

+68-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ structopt = "0.3"
1818
indexmap = "1.6"
1919
chrono = "0.4"
2020
glob = "0.3.0"
21+
encoding_rs = "0.8"
22+
encoding_rs_io = "0.1"
2123
codespan-reporting = "0.11.1"
2224

2325

examples/program_with_variables.st

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PROGRAM hello
22
VAR
3-
x : INT;
3+
x : INT
44
y : BOOL;
55
END_VAR
6+
IF x = 2 THEN
7+
x := 3
68
END_PROGRAM

0 commit comments

Comments
 (0)