# File raggle, line 1809
      def fix_character_encoding(element)
        meth = 'Channel#fix_character_encoding'

        # get character encoding
        enc = $config['character_encoding'] || 'ISO-8859-1'

        # check and see if we have iconv support
        if $HAVE_LIB['iconv'] && $config['use_iconv']
          unless $iconv
            # $iconv hasn't been intialized; create it
            enc += '//TRANSLIT' if $config['use_iconv_translit']
            $iconv = Iconv.new(enc, 'UTF-8')
          end

          # decode element using iconv
          element_text = element.text.to_s
          begin
            ret = $iconv.iconv(element_text) << $iconv.iconv(nil)
          rescue Iconv::IllegalSequence => e
            success_str = e.success
            ch, pending_str = e.failed.split(//, 2)
            ch_int = ch.to_i
            t = Time.now

            if String::UNICODE_LUT.has_key?(ch_int)
              err_str = _('converting unicode')
              $log.warn(meth) { "#{err_str} ##{ch_int}" }
              element_text = success_str + UNICODE_LUT[ch_int] + pending_str
            else
              if $config['iconv_munge_illegal']
                err_str = _('munging unicode')
                $log.warn(meth) { "#{err_str} ##{ch_int}" }
                munge_str = $config['unicode_munge_str']
                element_text = success_str + munge_str + pending_str
              else
                err_str = _('dropping unicode')
                $log.warn(meth) { "#{err_str} ##{ch_int}" }
                element_text = success_str + pending_str
              end
            end
            retry
          end                                                                 
        else
          # iconv isn't installed, or it's disabled; fall back to
          # the old (oogly) encoding behavior
          ret = (REXML::Output.new('', enc) << element.text).to_s
        end

        # return result
        ret.unescape_html
      end