summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e963583)
raw | patch | inline | side by side (parent: e963583)
author | Cedric Fung <cedric@vec.io> | |
Thu, 11 Apr 2013 07:11:29 +0000 (09:11 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 11 Apr 2013 07:11:29 +0000 (09:11 +0200) |
NEWS | patch | blob | history | |
lyrics/20-lyricwiki.rb | patch | blob | history |
index 59c0c84cf8b01366c0614defd5d46b45b751660f..a94f9bb82c77f432ae04297dc761a69c2186a1c5 100644 (file)
--- a/NEWS
+++ b/NEWS
* song format: evaluate literal strings as true
* fix crash on search screen when disconnected
* screen_queue: fix crash on CMD_SCREEN_SWAP when the queue is empty
+* lyricswiki: fix Ruby 2.0 and UTF-8
ncmpc 0.20 - (02/05/2012)
diff --git a/lyrics/20-lyricwiki.rb b/lyrics/20-lyricwiki.rb
index 87022492b95497a4659beb7f610190a02eba6610..56f61aa7943cd4487f9d996090ec6a222747f20f 100755 (executable)
--- a/lyrics/20-lyricwiki.rb
+++ b/lyrics/20-lyricwiki.rb
require 'uri'
require 'net/http'
require 'cgi'
-require 'iconv'
# We need this because URI.escape doesn't escape ampersands.
def escape(string)
exit(1)
end
-# lyrics come in Latin1, but we need UTF-8
-lyrics_latin1 = CGI::unescapeHTML($1.gsub(/<br \/>/, "\n"))
-puts Iconv.conv('UTF-8//TRANSLIT//IGNORE', 'Latin1', lyrics_latin1)
+lyrics = $1.gsub(/<br \/>/, "\n")
+
+if lyrics.respond_to?(:force_encoding)
+ puts CGI::unescapeHTML(lyrics.force_encoding(Encoding::UTF_8))
+else
+ $KCODE = 'U'
+ puts CGI::unescapeHTML(lyrics)
+end