SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting £ symbol to £

    My database is full of user inputted data which has loads of pound symbols in it '£'. BUt they output as a strange character.
    I know if I change them to £, they appear correctly but how can I do that en-masse.

    So far I have tried these options

    echo str_replace("£", "£", $row_rs_deals['description'])
    echo htmlspecialchars($row_rs_deals['description'])

    But neither work.

    Does anyone know what will convert them? Also, would it be better to convert them on the way into the databse in the future or is that impossible?

    Cheers

    Dave

  2. #2
    SitePoint Mentor silver trophybronze trophy
    Mikl's Avatar
    Join Date
    Dec 2011
    Location
    Edinburgh, Scotland
    Posts
    1,598
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this will work, but give it a try:

    Instead of this:

    Code:
    echo str_replace("£", "£", $row_rs_deals['description']);
    try this:

    Code:
    echo str_replace(chr(156), "£", $row_rs_deals['description']);
    Mike

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Close but no cigar! Still get a little square instead of the pound symbol.
    Any other ideas?

  4. #4
    SitePoint Mentor silver trophybronze trophy
    Mikl's Avatar
    Join Date
    Dec 2011
    Location
    Edinburgh, Scotland
    Posts
    1,598
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Ah well. It was just a shot in the dark. I hope someone else will give you the answer.

    Mike

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what is your character set in your page but did you try htmlentities() function something like this ?
    PHP Code:
    echo htmlentities('£hello'null'utf-8'); 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    ¬.¬ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You should just use UTF-8 then you can use the symbol without any conversions. ¢£¤¥
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UTF 8 as the characterset for the database table?


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
  •