diff --git a/lib/google-ime-skk.rb b/lib/google-ime-skk.rb index 2af9479..f4780cc 100644 --- a/lib/google-ime-skk.rb +++ b/lib/google-ime-skk.rb @@ -17,7 +17,7 @@ def encode_to_utf8(text) def encode_to_eucjp(text) if String.new.respond_to?(:encode) - text.encode('euc-jp', 'utf-8', {:invaild => true, :replace => '?'}) + text.encode('euc-jp', 'utf-8', invalid: :replace, undef: :replace, replace: '?') else require 'kconv' Kconv.toeuc(text) @@ -34,7 +34,8 @@ def social_ime_search(text) http.read_timeout = 1 http.open_timeout = 1 http.start do |h| - res = h.get("/transliterate?langpair=ja-Hira%7Cja&text=" + URI.escape(text)) + query = URI.encode_www_form(text: text, langpair: "ja-Hira|ja") + res = h.get("/transliterate?#{query}") obj = JSON.parse(res.body.to_s) encode_to_eucjp(obj[0][1].join('/')) end diff --git a/lib/socialskk.rb b/lib/socialskk.rb index 30024db..5c5c438 100755 --- a/lib/socialskk.rb +++ b/lib/socialskk.rb @@ -108,7 +108,8 @@ def social_ime_search(kana) http = Net::HTTP.new('www.social-ime.com', 80) http = Net::HTTP.new('www.social-ime.com', 80, @proxy.host, @proxy.port) if @proxy http.start do |h| - res = h.get("/api/?string=#{URI.escape(kana)}&resize[0]=+#{size}") + query = URI.encode_www_form(string: kana, "resize[0]": "+#{size}") + res = h.get("/api/?#{query}") kanji += res.body.to_s.split("\n").join('/').gsub(/\t/, '/') end end