Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-12-26 21:53:31 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2017-12-28 18:32:33 +0300
commit11247ac97c2e15d188878eb946cbc0817f705749 (patch)
treeeecd51e54a2c1b8d92799d34b3854efe9489292c /lib/gitlab/encoding_helper.rb
parent46be07d2c1da93cffd59fb03036e357c04ff6f3b (diff)
Move encoding methods to the more general EncodingHelper
Diffstat (limited to 'lib/gitlab/encoding_helper.rb')
-rw-r--r--lib/gitlab/encoding_helper.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb
index 582028493e9..6b53eb4533d 100644
--- a/lib/gitlab/encoding_helper.rb
+++ b/lib/gitlab/encoding_helper.rb
@@ -71,6 +71,16 @@ module Gitlab
end
end
+ def encode_binary(s)
+ return "" if s.nil?
+
+ s.dup.force_encoding(Encoding::ASCII_8BIT)
+ end
+
+ def binary_stringio(s)
+ StringIO.new(s || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
+ end
+
private
def clean(message)