diff options
| author | ruki <[email protected]> | 2026-01-15 00:57:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-15 00:57:06 +0800 |
| commit | dd18f22140b3d8a0a8491105f052df99273dab99 (patch) | |
| tree | f296f2d23ca08531267eaf041b12a23522dff78d /tests/modules/io/test.lua | |
| parent | 4ecd3eff0b966f7d16cf5d3dc413add12bb19486 (diff) | |
add io.convert
Diffstat (limited to 'tests/modules/io/test.lua')
| -rw-r--r-- | tests/modules/io/test.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/modules/io/test.lua b/tests/modules/io/test.lua index e4c6f23e1..1776baba2 100644 --- a/tests/modules/io/test.lua +++ b/tests/modules/io/test.lua @@ -94,3 +94,23 @@ function test_write(t) os.tryrm("temp") end + +function test_convert(t) + local src = "files/utf8bom-lf-eleof" + local dst = "temp/convert_test.txt" + os.mkdir("temp") + + -- utf8 to gbk + io.convert(src, dst, {from = "utf8", to = "gbk"}) + local content = io.readfile(dst, {encoding = "binary"}) + t:are_equal(content, "123\\\n456\n789\n") + + -- gbk to utf8 + local src_gbk = dst + local dst_utf8 = "temp/convert_test_utf8.txt" + io.convert(src_gbk, dst_utf8, {from = "gbk", to = "utf8"}) + content = io.readfile(dst_utf8, {encoding = "binary"}) + t:are_equal(content, "123\\\n456\n789\n") + + os.tryrm("temp") +end |
