Luodeni Posted March 1, 2009 Share Posted March 1, 2009 hey everyone, Earlier today I was doing some PHP programmign for a web application I m making and I got a very unpleasent error. My application is UTF-8 and that works fine. But when I was updating a record which uses chinese characters for example it just made a weird character. thsi was caused because I used <?php $companyStreetName = mysql_real_escape_string( ucfirst( $_POST['companystreetname'] ) ); ?> Now I found out the error was caused by the ucfirst() so I rewrote my code to this: <?php $companyName = mysql_real_escape_string( $_POST['companyname'] ); if ( ereg('[a-z]', $companyName) ) { $comapnyName = ucfirst( $companyName ); } else { $companyName; } ?> however It doesn't work for some reason, does anyone know why not? i d be very happy if someone could help me with this Quote Link to comment Share on other sites More sharing options...
RussellReal Posted March 1, 2009 Share Posted March 1, 2009 well the only thing I can see wrong with this is different character encoding, has different positions for the character for example, 32 would be the charCode for UTF-8 for a space, and 160 would be a non-breaking space in UTF-8, meanwhile in chinese they may have characters like this, like a b c, but I am not 100% positive, but I'd assume they'd be at different positions on that encoding.. and when everything boils down to it, everything is broken down to the asc value of the character in question although I'm not completely positive about any of the above, thats just about what I figure how happens, which would explain the ucfirst() failure and ereg failure to match the letters Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.