code: def span_case(self, i, case):
          
  
          # A new \L, \C or \E should pop the last in the stack.
          if self.span_stack:
              self.span_stack.pop()
          if self.single_stack:
              self.single_stack.pop()
          self.span_stack.append(case)
          count = len(self.span_stack)
          self.end_found = False
          try:
              while not self.end_found:
                  t = next(i)
                  if self.use_format and t in _CURLY_BRACKETS:
                      self.handle_format(t, i)
                  elif t == '\\':
                      try:
                          t = next(i)
                          self.reference(t, i)
                      except StopIteration:
                          self.result.append(t)
                          raise
                  else:
                      self.result.append(self.convert_case(t, case))
                  if self.end_found or count > len(self.span_stack):
                      self.end_found = False
                      break
          except StopIteration:
              pass
          if count == len(self.span_stack):
              self.span_stack.pop()
docs: Uppercase or lowercase the next range of characters until end marker is found.