diff options
author | Paul Schoenfelder <paulschoenfelder@gmail.com> | 2017-09-06 18:32:06 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 18:32:06 -0500 |
commit | f4c96bb1332e36635af617c9c3770bd4f52acaed (patch) | |
tree | 2487d86bdfd013fefce8f914f7f0d451f91dd19a /lib/exirc/utils.ex | |
parent | Merge pull request #69 from shymega/tweaks/readme (diff) | |
parent | Fallback to latin1 when we're not dealing with valid unicode (diff) |
Merge pull request #70 from w1gz/master
Fallback to latin1 when we're not dealing with valid unicode
Diffstat (limited to 'lib/exirc/utils.ex')
-rw-r--r-- | lib/exirc/utils.ex | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/exirc/utils.ex b/lib/exirc/utils.ex index 2573cc3..46cba11 100644 --- a/lib/exirc/utils.ex +++ b/lib/exirc/utils.ex @@ -76,7 +76,13 @@ defmodule ExIrc.Utils do |> Enum.filter(fn arg -> arg != [] end) |> Enum.map(&trim_crlf/1) |> Enum.map(&:binary.list_to_bin/1) - |> Enum.map(&:unicode.characters_to_binary/1) + |> Enum.map(fn(s) -> + case String.valid?(s) do + true -> :unicode.characters_to_binary(s) + false -> :unicode.characters_to_binary(s, :latin1, :unicode) + end + end) + post_process(%{msg | args: args}) end |