Skip to content

Fix UTF-8 encoding problem #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rt_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def compose(fields) # :nodoc:
# Helper to replace control characters with string representations
# When some XML libraries hit these in an XML response, bad things happen.
def sterilize(str)
str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
str.encode!('UTF-8', str.encoding.to_s, invalid: :replace, undef: :replace, replace: '')
str.gsub!(0x00.chr,'[NUL]')
str.gsub!(0x01.chr,'[SOH]')
str.gsub!(0x02.chr,'[STX]')
Expand Down