Skip to content

JSON.dump("\x82\xAC\xEF".b) no error with the C extension #634

Closed
@eregon

Description

@eregon

On json 2.7.2:

$ ruby -rjson/ext -e 'p JSON.dump("\x82\xAC\xEF".b)'
json-2.7.2/lib/json/common.rb:306:in `generate': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)
$ ruby -rjson/pure -e 'p JSON.dump("\x82\xAC\xEF".b)'
json-2.7.2/lib/json/pure/generator.rb:453:in `encode': "\x82" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

On json master:

$ ruby -rjson/ext -e 'p JSON.dump("\x82\xAC\xEF".b)'
"\"\\u0082\\u00ac\xEF\""
$ ruby -rjson/pure -e 'p JSON.dump("\x82\xAC\xEF".b)'
json-2.7.2/lib/json/pure/generator.rb:341:in `encode': "\x82" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions