Skip to content

Commit

Permalink
Binary to String
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnny Mikhael committed Jan 31, 2022
1 parent 5f539d8 commit 9f20c6a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/my_button_app/redis.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule MyButtonApp.Redis do

@moduledoc false
defp binary_to_str(session) do
str = String.codepoints(session)
arr = Enum.map(Enum.to_list(32..126), fn(n) -> <<n>> end)
arr = arr ++ Enum.map(Enum.to_list(128..255), fn(n) -> <<n>> end)
Enum.reduce(str, fn (w, accumulator) -> if w in arr, do: accumulator <> w, else: accumulator end)
end

end

0 comments on commit 9f20c6a

Please sign in to comment.