Closed gmcgibbon closed 4 years ago
I couldn't sleep so I worked on this w/o remembering your PR. I came up with nearly the same solution with some minor exceptions. I use b
instead of dup
simply because it is shorter. One real difference is that in the assertions I force the encoding to the encoding of the expected... This lets me have tests with binary (or other) data and it needs to match. (I guess I need some tests to JUST check the encodings on output tho).
I even had to work out the US-ASCII declaration from the test file because I just couldn't figure out how to write the damn test otherwise.
Thank you for your contribution. Sorry I overlooked it. I did give you credit in the commit.
Thanks @zenspider, happy to see this fixed! 😄
Currently,
ruby_parser
cannot unescape string literals with invalid encoding (in my tests, strings with unicode and binary characters). When scanning a file like this:The stack-trace ends at
ruby_parser-3.14.1/lib/ruby_lexer.rex.rb:163:in `gsub': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
. I've done two things to fix this:#process_string_literal
. It essentially does the same thing with a fallback to encode the unquoted literal content as ASCII-8BIT.