def norm_isbn_str(s):
  """
  Given an ISBN string, normalize the string so that it only contains 
  the relevant digits.
   
  This function drops all ASCII whitespace characters (tab, space,
  carriage return, line feed) and all ASCII characters that are not
  alphanumeric.
   
  It also converts all ASCII letters to uppercase.  Note that ISBN-10
  numbers may have an "X" as their check digit!
   
  This function does NOT guarantee that the value it returns is a valid
  ISBN.
   
  Passing a non-string as the parameter is equivalent to passing an 
  empty string.
   
  Parameters:
   
    s : str | mixed - the ISBN number string to normalize
   
  Return:
   
    the normalized ISBN string, which is NOT guaranteed to be valid
  """
  
  # If non-string passed, replace with empty string
  if not isinstance(s, str):
    s = ''
  
  # Begin with an empty result
  isbn = ''
  
  # Go through each character of the string
  for cc in s:
    
    # Get current character code
    c = ord(cc)
    
    # Handle based on character type
    if (c >= ord('a')) and (c <= ord('z')):
      # Lowercase letter, so transfer uppercase to normalized ISBN
      isbn = isbn + chr(c - 0x20)
    
    elif (c >= ord('A')) and (c <= ord('Z')):
      # Uppercase letter, so transfer to normalized ISBN
      isbn = isbn + chr(c)
    
    elif (c >= ord('0')) and (c <= ord('9')):
      # Digit, so transfer to normalized ISBN
      isbn = isbn + chr(c)
    
    elif (c >= 0x21) and (c <= 0x7e):
      # Non-alphanumeric symbol, so don't transfer
      pass
    
    elif (c == ord('\t')) or (c == ord('\r')) or \
          (c == ord('\n')) or (c == ord(' ')):
      # Whitespace, so don't transfer
      pass
    
    else:
      # Control or extended character, so transfer to normalized
      isbn = isbn + chr(c)

  # Return normalized string
  return isbn