# File lib/html5/tokenizer.rb, line 84
    def consume_number_entity(isHex)

      # XXX More need to be done here. For instance, #13 should prolly be
      # converted to #10 so we don't get \r (#13 is \r right?) in the DOM and
      # such. Thoughts on this appreciated.
      allowed = DIGITS
      radix = 10
      if isHex
        allowed = HEX_DIGITS
        radix = 16
      end

      char_stack = []

      # Consume all the characters that are in range while making sure we
      # don't hit an EOF.
      c = @stream.char
      while allowed.include?(c) and c != :EOF
        char_stack.push(c)
        c = @stream.char
      end

      # Convert the set of characters consumed to an int.
      charAsInt = char_stack.join('').to_i(radix)

      if charAsInt == 13
        @token_queue << {:type => :ParseError, :data => "incorrect-cr-newline-entity"}
        charAsInt = 10
      elsif (128..159).include? charAsInt
        # If the integer is between 127 and 160 (so 128 and bigger and 159
        # and smaller) we need to do the "windows trick".
        @token_queue << {:type => :ParseError, :data => "illegal-windows-1252-entity"}

        charAsInt = ENTITIES_WINDOWS1252[charAsInt - 128]
      end

      if 0 < charAsInt and charAsInt <= 1114111 and not (55296 <= charAsInt and charAsInt <= 57343)
        char = [charAsInt].pack('U')
      else
        char = [0xFFFD].pack('U')
        @token_queue << {:type => :ParseError, :data => "cant-convert-numeric-entity", :datavars => {"charAsInt" => charAsInt}}
      end

      # Discard the ; if present. Otherwise, put it back on the queue and
      # invoke parse_error on parser.
      if c != ";"
        @token_queue << {:type => :ParseError, :data => "numeric-entity-without-semicolon"}
        @stream.unget(c)
      end

      return char
    end