# File hexja, line 1063
def input_sub_ISO_2022_JP_1(uio, show, input7bitType)
  # 文字集合が切り替わっているかどうか調べ、
  # 現在の文字集合テーブルを返す。
  # 切り替わっていなければ nil を返す
  checkCS = lambda{
    bytes = [ uio.getc ]
    if bytes[0] == 033 || bytes[0] == 016 || bytes[0] == 017
      retval = nil
      $ISO_SEQ_TABLE.each{|isoSeq|
        if isoSeq.input.size < bytes.size
          (isoSeq.input.size...bytes.size).each{|i|
            uio.ungetc(bytes.pop)
          }
        elsif bytes.size < isoSeq.input.size
          (bytes.size...isoSeq.input.size).each{|i|
            bytes.push(uio.getc)
          }
        end
        if isoSeq.input == bytes
          show.isoSeq(bytes)
          retval = isoSeq
          break
        end
      }
      return retval if retval
    end
    uio.ungets(bytes)
    nil
  }

  while true
    while nextIsoSeq = checkCS.call
      isoSeq = nextIsoSeq
    end
    return if !isoSeq
    return if (isoSeq.csType == input7bitType ||
               isoSeq.csType == :asciiOrJisRoman)
    
    bytes = [ ]

    case isoSeq.csType
      
    when :jisKana               # 半角カタカナ
      byte = uio.getc
      bytes.push(byte)
      if byte == nil || !(0x21 <= byte && byte <= 0x5f)
        uio.ungetc(byte)
        return
      end
      unicode = to_unicode('CP932', [ byte | 0x80 ].pack('C'))
      
    when :ascii                 # ASCII
      byte = uio.getc
      bytes.push(byte)
      if byte == nil || 0x80 <= byte
        uio.ungetc(byte)
        return
      end
      unicode = byte

    when :jisRoman              # JIS ROMAN
      byte = uio.getc
      bytes.push(byte)
      if byte == nil || 0x80 <= byte
        uio.ungetc(byte)
        return
      end
      unicode = to_unicode('ISO-2022-JP', bytes.pack('C'))
      
    when :x94x94
      bytes.push(uio.getc)
      bytes.push(uio.getc)
      if !(bytes[0] && bytes[1] &&
           041 <= bytes[0] && bytes[0] <= 0176 &&
           041 <= bytes[1] && bytes[1] <= 0176)
        uio.ungets(bytes)
        return
      end
      begin
        unicode = to_unicode($iso2022jp1, isoSeq.isoSeq+bytes.pack('C*'))
      rescue Iconv::IllegalSequence, Iconv::InvalidCharacter
        uio.ungets(bytes)
        return
      end

    else
      uio.ungets(bytes)
      return
      
    end

    show.unicodeLetter(bytes, unicode)
    
  end
end