RUBY-224 encode JRuby strings with byte[]
This commit is contained in:
parent
3d1934a92c
commit
016743b015
2
Rakefile
2
Rakefile
|
@ -26,7 +26,7 @@ namespace :build do
|
|||
jar_dir = File.join(java_dir, 'jar')
|
||||
|
||||
jruby_jar = File.join(jar_dir, 'jruby.jar')
|
||||
mongo_jar = File.join(jar_dir, 'mongo-2.2.jar')
|
||||
mongo_jar = File.join(jar_dir, 'mongo-2.4.jar')
|
||||
bson_jar = File.join(jar_dir, 'bson-2.2.jar')
|
||||
|
||||
src_base = File.join(java_dir, 'src')
|
||||
|
|
Binary file not shown.
|
@ -293,7 +293,7 @@ public class RubyBSONEncoder extends BSONEncoder {
|
|||
else if ( val instanceof RubyObject ) {
|
||||
|
||||
if ( val instanceof RubyString ) {
|
||||
putRubyString(name, ((RubyString)val).getUnicodeValue() );
|
||||
putRubyString(name, (RubyString)val);
|
||||
}
|
||||
|
||||
else if (val instanceof RubySymbol) {
|
||||
|
@ -582,10 +582,13 @@ public class RubyBSONEncoder extends BSONEncoder {
|
|||
_putString(name, s.getSymbol(), SYMBOL);
|
||||
}
|
||||
|
||||
protected void putRubyString( String name , String s ) {
|
||||
_put( STRING , name );
|
||||
_putValueString( s );
|
||||
}
|
||||
protected void putRubyString( String name , RubyString s ) {
|
||||
byte[] bytes = s.getBytes();
|
||||
_put( STRING , name );
|
||||
_buf.writeInt( bytes.length + 1);
|
||||
_buf.write( bytes );
|
||||
_buf.write( (byte)0 );
|
||||
}
|
||||
|
||||
protected void putString(String name, String s) {
|
||||
_putString(name, s, STRING);
|
||||
|
|
Loading…
Reference in New Issue