Skip to content

Instantly share code, notes, and snippets.

@ryochin
Last active January 18, 2021 11:37
Show Gist options
  • Save ryochin/f9aafbe3c8b0bd96a2cbddb9f968f3a0 to your computer and use it in GitHub Desktop.
Save ryochin/f9aafbe3c8b0bd96a2cbddb9f968f3a0 to your computer and use it in GitHub Desktop.
[Elixir] remove UTF-8's BOM
@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