]> granicus.if.org Git - ejabberd/commitdiff
Improve previous commit
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Wed, 10 Jul 2019 21:13:39 +0000 (00:13 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Wed, 10 Jul 2019 21:13:39 +0000 (00:13 +0300)
src/translate.erl

index 12d5b6c044c889107568d5aa2df1d24e8df9ac76..2c277c5da74ffe18e627cfcf54ff7db41998f1b4 100644 (file)
@@ -147,10 +147,12 @@ load_file(File) ->
        {ok, Lines} ->
            lists:map(
              fun({In, Out}) ->
-                     try
-                         InB = unicode:characters_to_binary(In, utf8),
-                         OutB = unicode:characters_to_binary(Out, utf8),
-                         {{Lang, InB}, OutB}
+                     try {unicode:characters_to_binary(In, utf8),
+                          unicode:characters_to_binary(Out, utf8)} of
+                         {InB, OutB} when is_binary(InB), is_binary(OutB) ->
+                             {{Lang, InB}, OutB};
+                         _ ->
+                             {error, File, bad_encoding}
                      catch _:badarg ->
                              {error, File, bad_encoding}
                      end;