Last active
January 18, 2021 11:37
-
-
Save ryochin/f9aafbe3c8b0bd96a2cbddb9f968f3a0 to your computer and use it in GitHub Desktop.
[Elixir] remove UTF-8's BOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@doc """ | |
remove UTF-8's BOM | |
### Example | |
``` | |
iex> "\\uFEFFHello" |> MyProject.Util.remove_bom() | |
"Hello" | |
``` | |
""" | |
@spec remove_bom(String.t()) :: String.t() | |
def remove_bom(str) when is_binary(str), do: str |> String.replace_prefix("\uFEFF", "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment