php - Language specific characters to regular english chars -


i not sure start this, here want do:

users have textfield need input few words. problem page use people different countries, , enter "weird" latin charaters like: ž, Ä, Ü, đ, Ť, Á etc.

before saving base want convert them z, a, u, d, t, a... there way without making (i think there charaters cover):

 $string = str_replace(array('Č','Ä','Á','đ'), array('c','a','a','d'), $string); 

and, yes, know can save utf-8 in database, problem string later sent sms, , because of sms protocol nature, these "special" chars use more space in message regular english alphabet cahracters (i limited 120 chars, , if put "Ä" in message, take more 1 character place).

first of all, still store original characters in utf-8 in database. can "translate" them ascii characters upon retrieval. because if, say, in future sms adds utf-8 support (or want use user data else), you'll have original characters intact.

that said, can use iconv this:

iconv('utf-8', 'ascii//translit', $input);  //where $input contains "weird" characters 

see thread more info, including caveats of approach: php: replace umlauts closest 7-bit ascii equivalent in utf-8 string


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -