Skip to content

Commit

Permalink
fixes short code map file encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mneudert committed Feb 12, 2019
1 parent 0294a7c commit 11bf2d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.19.2-dev

- Bug fixes
- Short code maps are now stored in the correct file encoding (`UTF-8`) to allow parsing short code maps with characters like umlauts ([#15](https://github.com/elixytics/ua_inspector/issues/15))

## v0.19.1 (2019-01-05)

- Enhancements
Expand Down
6 changes: 3 additions & 3 deletions lib/ua_inspector/downloader/short_code_map_converter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule UAInspector.Downloader.ShortCodeMapConverter do
@spec write_yaml(list, :hash | :hash_with_list | :list, String.t()) :: :ok
def write_yaml(map, :hash, file) do
{:ok, _} =
File.open(file, [:write], fn outfile ->
File.open(file, [:write, :utf8], fn outfile ->
for {short, long} <- map do
IO.write(outfile, "- \"#{short}\": \"#{long}\"\n")
end
Expand All @@ -37,7 +37,7 @@ defmodule UAInspector.Downloader.ShortCodeMapConverter do

def write_yaml(map, :hash_with_list, file) do
{:ok, _} =
File.open(file, [:write], fn outfile ->
File.open(file, [:write, :utf8], fn outfile ->
for {entry, elements} <- map do
elementstring =
elements
Expand All @@ -54,7 +54,7 @@ defmodule UAInspector.Downloader.ShortCodeMapConverter do

def write_yaml(map, :list, file) do
{:ok, _} =
File.open(file, [:write], fn outfile ->
File.open(file, [:write, :utf8], fn outfile ->
for item <- map do
IO.write(outfile, "- \"#{item}\"\n")
end
Expand Down

0 comments on commit 11bf2d9

Please sign in to comment.