【07-24 问题求助】便签无法输入读取,烦请帮忙看看是哪里有问题
rainmeter吧
全部回复
仅看楼主
level 3
◎子湛 楼主
RT,这个便签已经顺利用了很多年,从来没有调整过设置和语句。有段时间没用了,再使用时突然发现无法输入也无法读取txt。
已经尝试过卸载重装雨滴、卸载重装皮肤,确定txt编码,都没有作用。麻烦大佬帮忙看看,感激不尽。
ERRO (01:34:02.278) : Script: notes.lua:53: could not read from E:\文档\Rainmeter\Skins\Elementary\Notes\notes.txt
NOTE (01:34:02.279) Elementary\Time\time-hm.ini: Refreshing skin
ERRO (01:34:18.395) : Script: notes.lua:41: could not write to E:\文档\Rainmeter\Skins\Elementary\Notes\notes.txt
NOTE (01:34:18.396) Elementary\Notes\notepad.ini: Refreshing skin
ERRO (01:34:18.398) : Script: notes.lua:53: could not read from E:\文档\Rainmeter\Skins\Elementary\Notes\notes.txt
2024年07月23日 17点07分 1
level 3
◎子湛 楼主
写入的dll似乎也正常。
2024年07月23日 17点07分 2
level 3
◎子湛 楼主
lua编码:
--[[
~ Some Unicode notes ~
Byte-order marks:
https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
The BOM for UTF-8 is '\239\187\191'
The BOM for UTF-16 LE is '\255\254'
Unicode in Rainmeter:
https://docs.rainmeter.net/tips/unicode-in-rainmeter/
A cursory read of the Rainmeter docs originally led me to believe that
all files (ini, lua, and txt) must be encoded in UTF-16 LE, but there
is actually a separate section on reading and writing Unicode files in Lua!
(It's at the end)
Takeaways:
1. The script file should be in UTF-16 LE
2. The file being read/written to should be UTF-8
3. Since the first character set of UTF-8 is identical to ANSI, always
write a UTF-8 byte-order mark so that the file is unambiguously UTF-8
--]]
path, contents = nil, ""
function Initialize()
path = SKIN:MakePathAbsolute(SKIN:GetVariable('notesfile', SKIN:ReplaceVariables('#@#notes.txt')))
contents = readFromFile()
end
function Update()
-- If update is not disabled, then the measure will read the file contents
-- on every update, so that changes to the text from other programs appear
-- contents = readFromFile()
return contents
end
function writeToFile(text)
local text = SELF:GetOption('temp')
local file = io.open(path, 'w')
assert(file, 'could not write to ' .. path)
local bom = '\239\187\191'
if text:sub(1, 3) == bom then
file:write(text)
else
file:write(bom, text)
end
file:close()
end
function readFromFile()
local file = io.open(path, 'r')
assert(file, 'could not read from ' .. path)
local text = file:read('*a')
file:close()
return text
end
2024年07月23日 17点07分 4
主楼错误提示说是notes.lua脚本第53行和第41行有错误嘛,不能读取与写入,或许所用的脚本有些写法是被新版抛弃的所以产生了错误,最近有更新过雨滴没呢?
2024年07月26日 04点07分
@somi 没有手动更新过,也许是雨滴自动更新导致的,谢谢你,感觉很有可能!我想想有没有新办法处理。
2024年07月29日 14点07分
level 3
◎子湛 楼主
ini编码发了就会被吞,指路我使用的皮肤地址:https://zhutix.com/skins/elementary-3-0/
2024年07月23日 17点07分 6
1