Thank you all for your inputs, greatly appreciated.
sneakyimp1 wrote:The ereg_replace statement in that code basically says "take everything that is NOT one of these characters and replace it with ¿" -- or, after you've changed the code as sid suggested it'll change it to the empty string instead.
Thank you for this clear explanation, I had kind of guessed that it had to do with replacing from the "replace" in ereg_replace, but didn't know what, and how, you puting it in plain English helped a lot.
sneakyimp wrote:You could try a space instead of the empty string.
Done so already, thank for confirming.
sneakyimp wrote:
As for a "solution", you haven't really specified what you are looking for. Additionally, I provided links to documentation that you might find helpful, but you appear to have no interest in it.
My apologies, I thought stating that "carriage return", and "special characters" change to ¿ was clear, obviously I failed.
Believe me I read it, but it just goes beyond my capabilities, I can kind of understand it (though your clear English translation is more clear), but putting it into practice is something else, that is for a NON expert who is afraid of compromising security.
sneakyimp wrote:If -- and I can only guess this is what you want -- you want to keep the newline characters, you'll need to add a newline char to the string of chars in the first parameter supplied to your ereg statement.
And you guess right, I would like to have the new line, and my special chracters display.
NogDog wrote:
To really, fully answer your question as to what I would do (making the bold assumption that I qualify as an experienced PHP programmer), I would need to know the precise functional requirements as to why this is being done at all. (E.g., would any of this be necessary if everything from the HTML output to the database configuration/connection supported UTF-8?)
Weedpacket wrote:With the same provisos as others have given (you know a lot more about your code than we do), using an inverted question mark as a replacement character for characters that cannot otherwise be represented is wrong; a proper replacement character should be used (encoded in HTML as either � or &#​65533😉. But, again, that depends on what the actual needs are (it shouldn't be used in domain names, for example, for security reasons).
As my last comment to sneakyimp I need to have the carriage return (new line), and special characters display in the email I get from my form.
First of all, I again apologize for not having been very clear about my need, secondly anyone here is an expert compared to my knowledge, thirdly I got this code from an existing form for a non-profit org that I am doing the work, and don't know who was the original coder.
The code was originally done to both send email, and to save into a database, and now I adapted it to only send the email.
It is a form for users of Italian, and English languages, the Italians have some accented vowels (i.e. à ò ì ù è) characters and when they fille the text area of the form, those characters are displayed as ¿ - now they are just empty spaces, as said earlier by removing the ¿ from ereg_replace; and obviously the carriage return.
While for the carriage return now with the emty space is readable, the special characters missing makes some text hard to interpret.
Basically my need is to add those special (accented) characters, and the new line to the ereg_replace [\' a-zA-Z0-9&!#$%()"+:?/@,_\.\-], if I got right sneakyimp's suggestion.
Of course it would be greatly appreciated if I can change the deprecated ereg with preg_replace, I mean is it sufficient to just change ereg_replace with preg_replace, or by doing so I need to change the whole line with new string that I wouldn't know how to write?
Thank you again.