Skip to content

Commit

Permalink
Bug - incorrectly converted
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed May 3, 2024
1 parent b7c3d6d commit 8b324e6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/whimsy/asf/string-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ def self.mreplace(text, regexp, &block)

# fix encoding errors
def self.fix_encoding(text)
result = text

if encoding == Encoding::BINARY
result = encode('utf-8', invalid: :replace, undef: :replace)

if text.encoding == Encoding::BINARY
return text.encode('utf-8', invalid: :replace, undef: :replace)
end
return text

result
end
end

Expand All @@ -79,4 +78,7 @@ def self.fix_encoding(text)
# puts txt
puts ASFString.word_wrap(txt)
puts ASFString.reflow(txt)
text="\x05\x00\x68\x65\x6c\x6c\x6f"
text.force_encoding(Encoding::BINARY)
puts ASFString.fix_encoding(text)
end

0 comments on commit 8b324e6

Please sign in to comment.