Only call force_encoding on ruby 1.9

This commit is contained in:
Tom Hughes 2012-11-12 20:19:07 +00:00
parent 461e39f4a5
commit 0472e6cad4

View file

@ -107,7 +107,7 @@ module Potlatch
# Encode string with two-byte length
def self.encodestring(n)
n=n.dup.force_encoding("ASCII-8BIT")
n=n.dup.force_encoding("ASCII-8BIT") if n.respond_to?("force_encoding")
a,b=n.size.divmod(256)
a.chr+b.chr+n
end