aboutsummaryrefslogtreecommitdiff
path: root/core/events.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-02-28 20:55:22 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-02-28 20:55:22 -0500
commitb1d103ecb28589d507477715f25fba5641d247c8 (patch)
tree2aff52d12db043853c2688added7c31e758460a1 /core/events.lua
parent36aaa46d7f71e3efa26a7fdf66fac537c060f414 (diff)
downloadtextadept-b1d103ecb28589d507477715f25fba5641d247c8.tar.gz
textadept-b1d103ecb28589d507477715f25fba5641d247c8.zip
Use UTF-8 internally and respect platform filename encoding.
Added 'textadept.iconv' function to interface with GLib's g_convert() and set global _CHARSET to be the platform's filename encoding/code page.
Diffstat (limited to 'core/events.lua')
-rw-r--r--core/events.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/events.lua b/core/events.lua
index b28b36ee..6767ebac 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -371,15 +371,17 @@ add_handler('save_point_left',
end)
add_handler('uri_dropped',
- function(uris)
+ function(utf8_uris)
local lfs = require 'lfs'
- for uri in uris:gmatch('[^\r\n\f]+') do
- if uri:find('^file://') then
- uri = uri:match('^file://([^\r\n\f]+)')
- uri = uri:gsub('%%20', ' ') -- sub back for spaces
- if WIN32 then uri = uri:sub(2, -1) end -- ignore leading '/'
+ for utf8_uri in utf8_uris:gmatch('[^\r\n\f]+') do
+ if utf8_uri:find('^file://') then
+ utf8_uri = utf8_uri:match('^file://([^\r\n\f]+)')
+ utf8_uri = utf8_uri:gsub('%%(%x%x)',
+ function(hex) return string.char(tonumber(hex, 16)) end)
+ if WIN32 then utf8_uri = utf8_uri:sub(2, -1) end -- ignore leading '/'
+ local uri = textadept.iconv(utf8_uri, _CHARSET, 'UTF-8')
if lfs.attributes(uri).mode ~= 'directory' then
- textadept.io.open(uri)
+ textadept.io.open(utf8_uri)
end
end
end