在LUA中复制文件时出现重音问题 [英] Problem with accents while copying files in LUA

查看:61
本文介绍了在LUA中复制文件时出现重音问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对法语Windows 10的口音有疑问

I have an issue with the accents with French Windows 10

local origin = "D:\temp\test.txt"
local destination = "D:\temp\testé.txt"
local cpTemplate = "copy \""..origin.."\" \""..destination.."\""
os.execute(cpTemplate)

控制台日志正确显示:

复制"D:\ temp \ test.txt"" D:\ temp \testé.txt"

这不会创建testé.txt"文件,但是:

This does not create a "testé.txt" file but:

testé.txt

当然,如果文件夹名称中带有重音符号(此处为D:\ temp),则不会复制任何内容

Of course, if there is an accent in the folder name (D:\temp here is an example), nothing is copied

推荐答案

标准Lua运行时库("io"模块)不支持将UTF8或UNICODE文件名写入磁盘,因为Lua依赖于ANSI C运行时库.您必须手动将文件名转换为Windows系统上使用的当前控制台代码页(如Darius建议的那样)

Standard Lua runtime library (the "io" module) does not support writing UTF8 or UNICODE filenames to disk, as Lua relies on the ANSI C runtime library. You have to manually convert the filename to the current console codepage used on your Windows system (as Darius suggested)

对于Windows,您还可以使用特定的Lua实现,该实现使用UTF8字符串,并且可以将UTF8文件名写入磁盘,例如LuaRT(https://www.luart.org )

You can also use a specific Lua implementation for Windows that uses UTF8 strings and can write UTF8 filenames to disk such as LuaRT (https://www.luart.org)

这篇关于在LUA中复制文件时出现重音问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆