def normalize_encoding(text)
if text.respond_to?(:encode)
begin
text.encode("UTF-8")
rescue
raise Prawn::Errors::IncompatibleStringEncoding, "Encoding " +
"#{text.encoding} can not be transparently converted to UTF-8. " +
"Please ensure the encoding of the string you are attempting " +
"to use is set correctly"
end
else
begin
text.unpack("U*")
return text.dup
rescue
raise Prawn::Errors::IncompatibleStringEncoding, "The string you " +
"are attempting to render is not encoded in valid UTF-8."
end
end
end