I\'ve just tested locally my web application, everything works fine, but after uploading to server application behaves differently. I use function formatiraj_string_url to c
I recommend you rely on existing, highly-tested code to do this. I believe all these functions assume UTF-8 input and output 7-bit ASCII:
utf8_to_ascii()
from the venerable PHP UTF8 project