Sha256: 73b0f79d60c68222fb38dabc4ed17d33a695d0d7badca7797c8194aaf0c05078
Contents?: true
Size: 843 Bytes
Versions: 3
Compression:
Stored size: 843 Bytes
Contents
# frozen_string_literal: true require 'rubygems' require 'rchardet' module Git # Method that can be used to detect and normalize string encoding module EncodingUtils def self.default_encoding __ENCODING__.name end def self.best_guess_encoding # Encoding::ASCII_8BIT.name Encoding::UTF_8.name end def self.detected_encoding(str) CharDet.detect(str)['encoding'] || best_guess_encoding end def self.encoding_options { invalid: :replace, undef: :replace } end def self.normalize_encoding(str) return str if str.valid_encoding? && str.encoding.name == default_encoding return str.encode(default_encoding, str.encoding, **encoding_options) if str.valid_encoding? str.encode(default_encoding, detected_encoding(str), **encoding_options) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lg_pod_plugin-1.0.8 | lib/git/encoding_utils.rb |
lg_pod_plugin-1.0.7 | lib/git/encoding_utils.rb |
lg_pod_plugin-1.0.6 | lib/git/encoding_utils.rb |