It should work with โcharacters matching this code,โ unless the client or another layer in the product chain fails your code!
Alternatively, use translate() or replace() for this simple job. Much faster than regexp_replace() . translate() also good for a few simple replacements at a time.
And avoid empty updates with a WHERE . Much faster and avoids the table boat and the extra cost of VACUUM .
UPDATE mytable SET myfield = translate(myfield, 'P', '`')
If you continue to encounter problems, use @mvp encoding, provided:
UPDATE mytable SET myfield = translate(myfield, U&'\0050', U&'\0060') WHERE myfield <> translate(myfield, U&'\0050', U&'\0060');
source share