Definitely NO.
Not because of some exotic encodings you will never meet in your life, but because of the simple fact that escaping alone helps nothing.
Adding slashes is not like some divine intervention that instantly prevents scaring injection.
In fact, it works only if combined with quotes. If you quote your escaped data - you may consider yourself safe, even with your home-brewed escaping function (as long as your encoding either single-byte or UTF-8). However, sometimes we don't (or even can't) use quotes around our variables and such a place instantly becomes a security hole.
For the further explanations you may refer to my previous answer to the similar question: https://stackoverflow.com/a/8061617/285587
As for the accepted answer, just keep in mind that both mysql_real_escape_string() and PDO prepared statements has exactly the same vulnerability if used by itself, without taking required precautions. You have to properly set client encoding to make them work as intended.
So, in fact just use mysql_real_escape_string()
will help you no more than your own function.
mysql_set_charset() have to be used with mysql_real_escape_string()
and in PDO either emulation mode have to be turned off or encoding should be set in DSN