Russian, scandinavian and some special characters are not encoded correctly. Which makes the Java+Spring hessian service throw an exception "unknown code:" when I'm using HessianRuby to communicate with it.
Logged In: NO
Iconv fixes the problem with writeStringData. I haven't found a solution for deserialize yet.
def writeStringData(o) writeLength(o.length) o = Iconv::iconv( "UTF-8", "ISO-8859-1", o )[0] puts o @s += o end
This code was snatched from the PHP version of hessian and it seems to fix the deserialize part of the bug:
def readNextString(length) count = 0 val = ""
length.times do char = @input[@offset..@offset]
@offset += 1 charCode = char[0]; if(charCode < 0x80) val = val + char elsif((charCode & 0xe0) == 0xc0) val = val + char + @input[@offset..@offset] @offset += 1 elsif ((charCode & 0xf0) == 0xe0) val = val + char + @input[@offset..@offset+1] @offset += 2 else raise "Bad utf-8 encoding" end end
val end
The writeStringData fixed the serialization part.
Here's a test case that shows this problem:
require 'hessianProxy' test = Hessian::HessianProxy.new("http://www.caucho.com/hessian/test/basic") test.echo("Itrntinliztin")
The output is: Invalid tag, expected 'r', received '<'
Log in to post a comment.
Logged In: NO
Iconv fixes the problem with writeStringData. I haven't
found a solution for deserialize yet.
def writeStringData(o)
writeLength(o.length)
o = Iconv::iconv( "UTF-8", "ISO-8859-1", o )[0]
puts o
@s += o
end
Logged In: NO
This code was snatched from the PHP version of hessian and
it seems to fix the deserialize part of the bug:
def readNextString(length)
count = 0
val = ""
length.times do
char = @input[@offset..@offset]
@offset += 1
charCode = char[0];
if(charCode < 0x80)
val = val + char
elsif((charCode & 0xe0) == 0xc0)
val = val + char + @input[@offset..@offset]
@offset += 1
elsif ((charCode & 0xf0) == 0xe0)
val = val + char + @input[@offset..@offset+1]
@offset += 2
else
raise "Bad utf-8 encoding"
end
end
val
end
The writeStringData fixed the serialization part.
Logged In: NO
Here's a test case that shows this problem:
require 'hessianProxy'
test =
Hessian::HessianProxy.new("http://www.caucho.com/hessian/test/basic")
test.echo("Itrntinliztin")
The output is:
Invalid tag, expected 'r', received '<'