Skip to content

Commit

Permalink
Change 'encoding' to "utf-8" before iconv_from_utf8() and restore 'en…
Browse files Browse the repository at this point in the history
…coding' after iconv_from_utf8().
  • Loading branch information
katono committed Jan 22, 2015
1 parent 8b0a891 commit 197b636
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions autoload/rogue/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ local function read_mesg()
end

if vim then
g.save_encoding = vim.eval('s:save_encoding')
if vim.eval('&encoding') ~= g.save_encoding then
g.save_encoding = g.get_vim_variable('s:save_encoding')
local needs_iconv = g.get_vim_variable("s:needs_iconv")
if needs_iconv ~= 0 then
g.needs_iconv = true
vim.command('let &encoding = "utf-8"')
for k, v in pairs(g.mesg) do
g.mesg[k] = g.iconv_from_utf8(v)
end
Expand Down
6 changes: 5 additions & 1 deletion autoload/rogue/rogue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ function! rogue#rogue#main(args)
let save_more = &more
let save_guicursor = &guicursor
set cpo&vim
let &encoding = 'utf-8'
if &encoding ==? 'utf-8'
let s:needs_iconv = 0
else
let s:needs_iconv = 1
endif
let &ruler = 0
let &showmode = 0
let &showcmd = 0
Expand Down
2 changes: 2 additions & 0 deletions autoload/rogue/save.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ function g.restore(fname)
end
g.xxx(true)
buf = g.xxxx(buf)
vim.command('let &encoding = "utf-8"')
buf = g.iconv_from_utf8(buf)
vim.command('let &encoding = s:save_encoding')
local Rogue_copy = assert(g.loadstring('return ' .. buf), g.mesg[508])()

if g.home_dir ~= Rogue_copy.home_dir then
Expand Down
2 changes: 2 additions & 0 deletions autoload/rogue/score.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ function g.put_scores(monster, other)
local buf = fp:read("*a")
g.xxx(true)
buf = g.xxxx(buf)
vim.command('let &encoding = "utf-8"')
buf = g.iconv_from_utf8(buf)
vim.command('let &encoding = s:save_encoding')
scores = assert(g.loadstring('return ' .. buf), g.mesg[199])()
fp:close()
end
Expand Down

0 comments on commit 197b636

Please sign in to comment.