Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb30eec

Browse files
committed
Merge pull request reactjs#52 from chenxsan/fix-utf-8-server-ruby
fix failing to write utf-8 encoded characters into comments.json with ruby server
2 parents e414ac6 + 840951e commit bb30eec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323

2424
if req.request_method == 'POST'
2525
# Assume it's well formed
26-
comments << req.query
26+
comment = {}
27+
req.query.each do |key, value|
28+
comment[key] = value.force_encoding('UTF-8')
29+
end
30+
comments << comment
2731
File.write('./comments.json', JSON.pretty_generate(comments, :indent => ' '))
2832
end
2933

0 commit comments

Comments
 (0)