I am at a lost of how to remove special characters from a string to make sure that only chars supported by uft-8 + French chars are included. The below base64 string has special chars and the my sanitizing function has failed to remove them and this is causing the text not to print when using FPDF cells etc. If you decode the string at https://www.base64decode.org/ you will see the special chars.
// My sanitizing function
static function remove_none_word_chars($string) {
return preg_replace('/[^a-zA-Z0-9`_.,;@#%~\’\'\"+*\?\^\[\]\$\(\)\{\}\=!\<\>\|\-:\s\/\\sàâçéèêëîïôûùüÿñæœ]/ui', '', $string);
}
74KnIFN1cGVydmlzZXIgbGUgdHJhdmFpbCBkZSBs4oCZZW5zZW1ibGUgZHUgcGVyc29ubmVsIGRlIHByb2R1Y3Rpb24sIGRlIGzigJllbnRyZXRpZW4gZXQgZGUgbGEgbWFpbnRlbmFuY2Ugc3VyIGxlIHF1YXJ0IGRlIG51aXQgZW4gdGVuYW50IGNvbXB0ZSBkZSBsYSBjb252ZW50aW9uIGNvbGxlY3RpdmU7Cu+CpyBBc3N1cmVyIHVuZSBib25uZSBnZXN0aW9uIGRlIGzigJllbnNlbWJsZSBkZXMgb3DDqXJhdGlvbnMgZGUgbOKAmXVzaW5lOwrvgqcgUGxhbmlmaWVyIGRlcyBvcMOpcmF0aW9ucyBlbiBmb25jdGlvbiBkZXMgYm9ucyBkZSBjb21tYW5kZTsK74KnIEFwcG9ydGVyIGxlcyBtb2RpZmljYXRpb25zIGV4aWfDqWVzIGxvcnMgZGVzIGRpZmbDqXJlbnRzIGF1ZGl0cyAoR2VuZXJhbCBEeW5hbWljcywgSVNPOTAwMSwgT0hTQVMxODAwMSwgZXRjLik7Cu+CpyBSZW5kcmUgY29tcHRlIGR1IHN1aXZpIGRlcyBvcMOpcmF0aW9ucyDDoCBjaGFxdWUgZGlyZWN0ZXVyIGRlIGTDqXBhcnRlbWVudCBsb3JzIGR1IGNoYW5nZW1lbnQgZGUgcXVhcnQ7Cu+CpyBWb2lyIGF1IHN1aXZpIGRlcyBidWRnZXRzIGV0IGVuIGFzc3VyZXIgbGUgcmVzcGVjdC4=
Update Thanks all for the answers the above function does indeed work there was a conditional statement I forgot to change elsewhere thats way :( embarrassing.