Skip to content

Commit

Permalink
Add encoding to file open
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwgd committed Oct 16, 2021
1 parent d666d5d commit f96913a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_bootstrap_icons/templatetags/bootstrap_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def icon(icon_path, icon_name, size=None, color=None, extra_classes=None):
cache_file = os.path.join(cache_path, cache_name)
if os.path.exists(cache_file):
# icon exists in cache, use that
with open(cache_file, 'r') as icon_file:
with open(cache_file, 'r', encoding="utf-8") as icon_file:
return icon_file.read()

# cached icon doesn't exist or no cache configured, create and return icon
Expand All @@ -129,7 +129,7 @@ def icon(icon_path, icon_name, size=None, color=None, extra_classes=None):
svg = render_svg(content, size, color, extra_classes)
# if cache configured write icon to cache
if cache_path and cache_file:
with open(cache_file, 'w') as icon_file:
with open(cache_file, 'w', encoding="utf-8") as icon_file:
icon_file.write(svg)
except requests.ConnectionError:
return getattr(
Expand Down

0 comments on commit f96913a

Please sign in to comment.