diff options
author | Hiroshi SHIBATA <[email protected]> | 2020-01-11 21:37:00 +0900 |
---|---|---|
committer | SHIBATA Hiroshi <[email protected]> | 2020-01-12 12:28:29 +0900 |
commit | c3ccf23d5807f2ff20127bf5e42df0977bf672fb (patch) | |
tree | d3953c32b61645c7af65d30e626af944f143cf58 /lib/rexml/encoding.rb | |
parent | 012f297311817ecb19f78c55854b033bb4b0397c (diff) |
Make rexml library to the bundle gems
[Feature #16485][ruby-core:96683]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2832
Diffstat (limited to 'lib/rexml/encoding.rb')
-rw-r--r-- | lib/rexml/encoding.rb | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb deleted file mode 100644 index da2d70d6c9..0000000000 --- a/lib/rexml/encoding.rb +++ /dev/null @@ -1,51 +0,0 @@ -# coding: US-ASCII -# frozen_string_literal: false -module REXML - module Encoding - # ID ---> Encoding name - attr_reader :encoding - def encoding=(encoding) - encoding = encoding.name if encoding.is_a?(Encoding) - if encoding.is_a?(String) - original_encoding = encoding - encoding = find_encoding(encoding) - unless encoding - raise ArgumentError, "Bad encoding name #{original_encoding}" - end - end - return false if defined?(@encoding) and encoding == @encoding - if encoding - @encoding = encoding.upcase - else - @encoding = 'UTF-8' - end - true - end - - def encode(string) - string.encode(@encoding) - end - - def decode(string) - string.encode(::Encoding::UTF_8, @encoding) - end - - private - def find_encoding(name) - case name - when /\Ashift-jis\z/i - return "SHIFT_JIS" - when /\ACP-(\d+)\z/ - name = "CP#{$1}" - when /\AUTF-8\z/i - return name - end - begin - ::Encoding::Converter.search_convpath(name, 'UTF-8') - rescue ::Encoding::ConverterNotFoundError - return nil - end - name - end - end -end |