s/([^\x00-\xFF])/sprintf "&#x%x;", $1/eg; # Encode s/&#x(\p{AHex}+);/chr hex $1/eg; # Decode