Skip to content

Commit

Permalink
Force UTF-8 encoding on sending data
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernard Potocki committed Jun 29, 2010
1 parent 2c113ce commit ede9793
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/em-websocket/connection.rb
Expand Up @@ -164,8 +164,9 @@ def process_message
# a leading length indicator
def send(data)
debug [:send, data]
data.force_encoding('ASCII-8BIT') if data.respond_to?(:force_encoding)
send_data("\x00#{data}\xff")
ary = ["\x00", data, "\xff"]
ary.collect{ |s| s.force_encoding('UTF-8') if s.respond_to?(:force_encoding) }
send_data(ary.join)
end
end
end
Expand Down

0 comments on commit ede9793

Please sign in to comment.