I have different types of kiosk printers for different purposes but i want to have a single printer class
the idea is tho store string like this in database
"\x1B\x40\x1B\x21\x28\x1B\x61\x31\nText line with %1 parameters\nand %2 something"
the first few characters initialize printer and set options (for different printers different initialization)

1. I need to load this string from database
2. convert escaped sequences ( "\x1B" becomes single character 27)
3. process parameter text (%1 is replaced with string)
4. write the result to serial port and to get ticket

Is this proper way or someone knows a better solution?
Anway i am stuck at task no. 2, how to process part of string that represents escape sequence
i have no idea how to do this task
I am using qt5 with c++11 config so new features of language are welcome
some google results pointed to toRaw and fromRaw functions but
to be honest i dont know how to present this problem with "multi level escape usage"