Don't crash on UTF-8 input

This commit is contained in:
Mikko Ahlroth 2013-08-05 21:01:11 +03:00
parent f1d7e8a753
commit 999c215578
2 changed files with 4 additions and 2 deletions

View file

@ -35,7 +35,8 @@ defmodule Nulform.IRC do
[sender, "PRIVMSG", target | text] ->
<<":", sender :: binary>> = sender
new_msg = PRIVMSG.new [info: msg, sender: sender,
target: target, text: Enum.join(text, " ")]
target: target,
text: Nulform.Utilities.to_utf8 Enum.join(text, " ")]
_ ->
nil

View file

@ -30,7 +30,8 @@ defmodule Nulform do
def listen_loop(urlanalyzer) do
receive do
{:nulform, :msg_in, msg} ->
IO.puts(to_binary(msg.connection_id) <> " -> " <> msg.raw_msg)
IO.puts(to_binary(msg.connection_id) <> " -> "
<> Nulform.Utilities.to_utf8 msg.raw_msg)
:gen_server.cast urlanalyzer, msg
case String.split msg.raw_msg do