How do I set application_name so that it doesn’t get the “?” characters?


I have this UTF-8 string in PHP:

$  test_title = 'My criticál business applicätiön'; 

If I send that to PostgreSQL to set the application_name, it then looks like this:

My critic?l business applic?ti?n 

If I try to salvage it by transliterating like this before sending to PG:

$  test_title = iconv('UTF-8', 'US-ASCII//TRANSLIT', $  test_title)); 

Then I get:

My critic'al business applic"ati"on 

Basically just as bad. It tries its best to represent the UTF-8 characters as the US-ASCII charset that PG demands for the application_name, but it just doesn’t look right. It cannot possibly look right because US-ASCII simply doesn’t contain all the non-USA characters.

Unfortunately, there also exist people outside of the USA. (I know, it’s annoying, but it’s sadly true.)

I refuse to believe that application_name must be ugly like this. It cannot be. It’s too stupid to be true. I must be missing something. There has got to be some way to set application_name to the actual application name and not have it butchered in the above manner.

Basically, I don’t "buy" that PG would be this primitive and crippled still in year 2020.