def find_suitable_encoding(self, char):
sorted_encodings = sorted(<EOL>self.codepages.items(),<EOL>key=self.__encoding_sort_func)<EOL>for encoding, _ in sorted_encodings:<EOL><INDENT>if self.can_encode(encoding, char):<EOL><INDENT>self.used_encodings.add(encoding)<EOL>return encoding<EOL><DEDENT><DEDENT>
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.