Skip to content

Commit

Permalink
Merge pull request #1853 from OpenC3/ensure_utf8
Browse files Browse the repository at this point in the history
Ensure target_file returns utf-8 files
  • Loading branch information
ryanmelt authored Jan 24, 2025
2 parents 3f53cbf + 8593dc7 commit 96e0625
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions openc3/lib/openc3/utilities/target_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ def self.body(scope, name)
# First try opening a potentially modified version by looking for the modified target
if ENV['OPENC3_LOCAL_MODE']
local_file = OpenC3::LocalMode.open_local_file(name, scope: scope)
return local_file.read if local_file
if local_file
if File.extname(name) == ".bin"
return local_file.read
else
return local_file.read.force_encoding('UTF-8')
end
end
end

bucket = Bucket.getClient()
Expand All @@ -106,8 +112,10 @@ def self.body(scope, name)
if resp && resp.body
if File.extname(name) == ".bin"
resp.body.binmode
return resp.body.read
else
return resp.body.read.force_encoding('UTF-8')
end
resp.body.read
else
nil
end
Expand Down

0 comments on commit 96e0625

Please sign in to comment.