Here is an example rtf file that shows two ways how the word 'łacińskim' can be written:
{\rtf1\ansi\ansicpg852\uc0 [\'88aci\'e4skim] [łacińskim] }
The first word is written using shielded \'xx sequences, where xx is a byte written in hexadecimal, representing the character encoded in the cp852 encoding.
The second word is written directly in cp852 encoding. When saving an rtf file, make sure that the cp852 encoding is used. For example, on my system, if I copy this text and paste it into a text file, it will be saved in utf-8 encoding and in order to get the desired file, you need to execute the command additionally:
$ iconv --from utf-8 --to cp852 polish.rtf | sponge polish.rtf
When generating a file using Python, it is enough to explicitly specify the encoding:
#!/usr/bin/env python3 from pathlib import Path text = Path('test.rtf').read_text(encoding='cp852') text = text.replace('LATIN_PLACEHOLDER', 'łacińskim') Path('generated.rtf').write_text(text, encoding='cp852')
Note that the Python code is encoded in utf-8 (nothing needs to be changed).
TEL_TAGshould be encoded using\',\u-. - jfs