Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save atomicules/289714 to your computer and use it in GitHub Desktop.
Save atomicules/289714 to your computer and use it in GitHub Desktop.
# Dummy line so it doesn't try to pick up encoding from below
# Testing "uninitialized constant Encoding::UTF_16BE" error
# that occurs in Shoes Policeman built with Ruby 1.9.1
# The below works in Shoes 2, but not in Shoes 3
#
# Problem seems to be in CGI
# See \dist\ruby\lib\cgi\utli.rb lines 37 onwards:
=begin
# Unescape a string that has been HTML-escaped
# CGI::unescapeHTML("Usage: foo "bar" <baz>")
# # => "Usage: foo \"bar\" <baz>"
def CGI::unescapeHTML(string)
enc = string.encoding
if [Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].include?(enc)
=end
#
# If you comment out lines 42 to 55 of util.rb it 'fixes' the problem.
require 'CGI'
Shoes.app do
stack do
@textentry = edit_line "Google is here: http://www.google.com"
@button = button "OK" do
bta =[]
@textentry.text.split.each do |word|
wordval = if word =~ /http[s]?:\/\/\S+/
link(word, :click => word)
else
CGI::unescapeHTML(word)
end
bta << wordval
bta << " "
end
para(bta)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment