SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Foreign characters in PHP and mySQL

    Is there a short way to replace all foreign characters in PHP and mySQL, e.g. HTML entites?

    I know that I can use str_replace("%21", "!", $string) when using forms

    to change all %21 (i.e. !) to ! but I have the whole ASCII table to use and I wasn't sure if there was a general way of doing this. (I have had to do it manually in perl anyway)

    Also can mySQL accept foreign characters I am more concerned with umlaut etc than !$ etc...

    Any ideas?

    Thanks

    Sarah

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not sure what you are doing but here are a couple of thoughts:

    1. $str = urlencode($str); This will escape all of your foreign characters, along with spaces. Maybe your solution is to use the urlencode() function and then find and replace whatever you want.

    2. $str = htmlentities($str); This will escape your characters so that they can be safely displayed in html.

    Is this what you're looking for?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •