code: def find_suitable_encoding(self, char):
          
          sorted_encodings = sorted(
              self.codepages.items(),
              key=self.__encoding_sort_func)
  
          for encoding, _ in sorted_encodings:
              if self.can_encode(encoding, char):
                  # This encoding worked; at it to the set of used ones.
                  self.used_encodings.add(encoding)
                  return encoding
docs: The order of our search is a specific one:
  
          1. code pages that we already tried before; there is a good
             chance they might work again, reducing the search space,
             and by re-using already used encodings we might also
             reduce the number of codepage change instructiosn we have
             to send. Still, any performance gains will presumably be
             fairly minor.
  
          2. code pages in lower ESCPOS slots first. Presumably, they
             are more likely to be supported, so if a printer profile
             is missing or incomplete, we might increase our change
             that the code page we pick for this character is actually
             supported.