php newbie Posted April 6, 2010 Report Share Posted April 6, 2010 ir tads testa scripts <? ini_set('error_reporting', E_ALL); ini_set ('display_errors', 1); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <form method="POST" action="test.php"> <input name="test_input" value="<? $some_text = isset($_POST['test_input']) ? $_POST['test_input'] : "ā ē ū ī ā š ģ ķ ļ č ņ"; $some_text = preg_replace("/[^A-Za-z0-9а-яА-Я!@#%()-==~.,?+ ]/", ' ', $some_text); echo $some_text; ?>" type="text" size="30" /> <input class="button" value="POST" type="submit" /> </form> </body> </html> un preg_replace sačakarē dažus latviešu burtus. laikam tas patterns bišķ sķībs. varbūt kādus rezervētus simbolus lietoju(+?), bet nu vienalga rezultāts pārsteidz Quote Link to comment Share on other sites More sharing options...
briedis Posted April 6, 2010 Report Share Posted April 6, 2010 Kādā kodējumā ir pats fails? Quote Link to comment Share on other sites More sharing options...
php newbie Posted April 6, 2010 Author Report Share Posted April 6, 2010 Kādā kodējumā ir pats fails? utf-8 Quote Link to comment Share on other sites More sharing options...
briedis Posted April 6, 2010 Report Share Posted April 6, 2010 A kāds tad ir tas rezultāts? (skrīnšotu moš pievieno, ja te nevar pārkopēt tos ķeburus) Quote Link to comment Share on other sites More sharing options...
php newbie Posted April 6, 2010 Author Report Share Posted April 6, 2010 labi ieliku it kā korektu paternu $some_text = preg_replace("/[^āēč]/", ' ', $some_text); // visus simbolus kas nav āēč aizstaj ar atstarpi un ievadot "āēģč" sanāk "āē� č" Quote Link to comment Share on other sites More sharing options...
php newbie Posted April 6, 2010 Author Report Share Posted April 6, 2010 t.i. atstarpi ģ vietā ielika, bet arī pielika kkādu figņu Quote Link to comment Share on other sites More sharing options...
briedis Posted April 6, 2010 Report Share Posted April 6, 2010 Piemet unicode flagu - preg_replace("/[^āēč]/u", " ", "āēģč") būtu jāstrādā... Quote Link to comment Share on other sites More sharing options...
php newbie Posted April 6, 2010 Author Report Share Posted April 6, 2010 aizgāja, paldies! Quote Link to comment Share on other sites More sharing options...
briedis Posted April 6, 2010 Report Share Posted April 6, 2010 aizgāja, paldies! gūglēt vajag, gūglēt :) pēc "preg_replace unicode" būtu atradis vajadzīgo.. 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.