You seem to have some encoding-related logic here... Parser already performs its own encoding processing here: https://github.com/whitequark/parser/blob/master/lib/parser/source/buffer.rb#L9