Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/edn/string_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module StringTransformer
def self.parse_string(string)
string = string.to_s
return '' if string.empty?
string.force_encoding Encoding::ASCII_8BIT
string = string.gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
#" Clear messed up syntax highlighting with Emacs.
if u = UNESCAPE_MAP[$&[1]]
Expand Down
7 changes: 7 additions & 0 deletions spec/edn/transform_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'spec_helper'

describe EDN::Transform do
Expand Down Expand Up @@ -26,6 +27,12 @@
subject.apply(:string => 'hello\n#{world}').should == "hello\n\#{world}"
end
end

context "string-utf8" do
it "should emit a string that preserves utf-8 characters" do
subject.apply(:string => 'öhai world').should == "öhai world"
end
end

context "keyword" do
it "should emit a Ruby symbol" do
Expand Down