Special-casing multiple code paths based on charset is a good sign that we should extract the charset-specific coding/decoding operations.

I suggest introducing something like a `CharsetCodec` that's responsible for them.

```ruby
CharsetCodec.find(charset) #=> ISO2022JPCodec

class CharsetCodec
  @codecs = Hash.new { |h, k| h[k] = CharsetCodec.new }
  def self.find(name) @codecs[name] end
  def self.register(name, codec) @codecs[name] = codec end

  def encode_address(value)
    value
  end

  def remap_characters(value)
    value
  end
end

class ISO2022JPCodec < CharsetCodec
  def encode_address(value)
    if value.kind_of?(Array)
      value.map { |e| encode_address e }
    elsif value =~ / <[\x00-\x7f]*>\z/
      encode value
    else
      value
    end
  end

  def remap_characters(value)
    # Mail::Preprocessor.process goes here
    value.gsub(REMAP_MATCH) { |c| REMAP[c] }
  end

  def encode(string)
    RubyVer.encode_with_iso_2022_jp string
  end
end

CharsetCodec.register 'iso-2022-jp', ISO2022JPCodec.new
```