From: elijah Date: Wed, 8 May 2013 07:15:18 +0000 (-0700) Subject: attempt to fix file loading problem when the OS has a weird default encoding. X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=115f471d6244fcaf4f68e99d729ef10c72289ccb;p=leap%2Fleap_cli.git attempt to fix file loading problem when the OS has a weird default encoding. --- diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index f5282c5..0d14541 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -185,11 +185,13 @@ module LeapCli log :loading, filename, 2 # - # read file, strip out comments - # (File.read(filename) would be faster, but we like ability to have comments) + # Read a JSON file, strip out comments. + # + # UTF8 is the default encoding for JSON, but others are allowed: + # https://www.ietf.org/rfc/rfc4627.txt # buffer = StringIO.new - File.open(filename) do |f| + File.open(filename, "rb") do |f| while (line = f.gets) next if line =~ /^\s*\/\// buffer << line