From 6bf9a36e4d86c0c1869f99650b9b05c44200a94c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 Aug 2014 22:34:40 +0000 Subject: dtas-console: force encoding for current locale This is the one place we display the filename for users, so it should hopefully make it displayable. Users who care about proper display should use a locale which matches their music collection (or rename their music collection to match). --- bin/dtas-console | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'bin/dtas-console') diff --git a/bin/dtas-console b/bin/dtas-console index 5747515..c28d92d 100755 --- a/bin/dtas-console +++ b/bin/dtas-console @@ -104,6 +104,9 @@ def rg_string(rg, current) rv end +enc_locale = Encoding.find("locale") +$stdout.set_encoding(enc_locale) +enc_opts = { undef: :replace, invalid: :replace, replace: '?' } begin Curses.init_screen Curses.nonl @@ -118,7 +121,15 @@ begin if current = cur['current'] Curses.setpos(lineno += 1, 0) Curses.clrtoeol - Curses.addstr(current['infile'] || current['command']) + if infile = current['infile'] + # FS encoding != locale encoding, but we need to display an FS path + # name to whatever locale the terminal is encoded to, so force + # it and risk mojibake... + infile.encode(enc_locale, enc_opts) + Curses.addstr(infile) + else + Curses.addstr(current['command']) + end elapsed = Time.now.to_f - current['spawn_at'] if (nr = cur['current_initial']) && (current_format = current['format']) -- cgit v1.2.3-24-ge0c7