diff options
author | w1gz <w1gz@noreply.com> | 2017-09-06 23:50:13 +0200 |
---|---|---|
committer | w1gz <w1gz@noreply.com> | 2017-09-06 23:53:29 +0200 |
commit | 96578d178ccee8f591b01ea4762bec8a0112a8ad (patch) | |
tree | 2487d86bdfd013fefce8f914f7f0d451f91dd19a /lib | |
parent | Merge pull request #69 from shymega/tweaks/readme (diff) |
Fallback to latin1 when we're not dealing with valid unicode
Diffstat (limited to 'lib')
-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 |