1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00

force UTF-8 encoding on all strings returned from javascript. V8 only officially supports Ascii and UTF-8 with limited support for UTF-16

This commit is contained in:
Charles Lowell 2011-03-09 10:08:30 -06:00
parent 11d0e86c0e
commit f4d9a6269b
2 changed files with 5 additions and 5 deletions

View file

@ -81,7 +81,7 @@ module V8
when V8::C::Function then peer(value) {V8::Function}
when V8::C::Array then peer(value) {V8::Array}
when V8::C::Object then peer(value) {V8::Object}
when V8::C::String then value.Utf8Value()
when V8::C::String then value.Utf8Value.tap {|s| return s.respond_to?(:force_encoding) ? s.force_encoding("UTF-8") : s}
when V8::C::Date then Time.at(value.NumberValue() / 1000)
when V8::C::Value then nil if value.IsEmpty()
else
@ -94,7 +94,7 @@ module V8
when V8::Object
value.instance_eval {@native}
when String
C::String::New(value.to_s)
C::String::New(value)
when Symbol
C::String::NewSymbol(value.to_s)
when Proc,Method,UnboundMethod
@ -107,8 +107,8 @@ module V8
end
when ::Hash
C::Object::New().tap do |o|
value.each do |key, value|
o.Set(v8(key), v8(value))
value.each do |key, val|
o.Set(v8(key), v8(val))
end
end
when ::Time

@ -1 +1 @@
Subproject commit 5bbbc5b23bd7fb9f747fdea52eb0bbfcf34959ee
Subproject commit 222bf1b12fe6b58293668d8d8bed9a0dd968a9e8