SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieving £ from db, want to keep it in that format

    Hi,

    The following characters sometimes appear at the top of my web page: 
    It seems to only happen when I'm trying to display the £ symbol on my website in Firefox. In front of each £ symbol it has a Â.

    I've got the £ symbol stored in my database as £ do I need to do anything special to stop it converting to £ when on the web page?

    Perfect world I'd want £ in my HTML rather than it being converted to £.

    My charset is <meta http-equiv="content-type" content="text/ html;charset=utf-8" />


    Thank you for any help.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Every & you want to display in your web page needs to be specified as &amp;
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but I would like to also display &pound; in my web page, but Firefox seems to change it to when its coming from the db, which is giving me problems.

    Would it be harmful to change my Charset from UTF-8 to something else?

    Like I say, it's a fairly intermittent issue, but I'd prefer not to have it at all

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Definitely seems to be a UTF-8 encoding issue.

    I'm taking the value &pound; from my db and 99&#37; it displays the pound symbol fine, but sometimes it adds the &#239;&#187;&#191; to the top of my page and then &#194; in front of some of my &#163; symbols.

    Has anyone found a fix for this?


    I may have to just display the pound symbols client-side if there's no way around it.

  5. #5
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by invision2 View Post
    Would it be harmful to change my Charset from UTF-8 to something else?
    No. I always use ISO-8859-1 to avoid just such UTF-8 tomfoolery.

    As felgall said, you have to use the HTML entity for ampersand in order to display an ampersand on a page:

    & a m p ; p o u n d ;

    (Remove the spaces.)

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aaaaaah, so even for &pound; I have to use &amp;pound; ???

    I'm using UTF-8 just now, should I expect any major issues if I change my Charset?


    Thanks for your help.

  7. #7
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by invision2 View Post
    Aaaaaah, so even for &pound; I have to use &amp;pound; ???
    Only if you want to display the entity code instead of the actual pound symbol. Otherwise, just use the entity code.

    Quote Originally Posted by invision2 View Post
    I'm using UTF-8 just now, should I expect any major issues if I change my Charset?
    I've never had any problems with ISO-8859-1, whereas I've had the same problems you described with UTF-8.

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right. I want to display the &#163; symbol, so I'll just use &pound; or & # 1 6 3 ; ?

    Sorry to ask again, but will I lose my valid XHTML if I change charset? All the data is taken from a MySQL database - do I need to make any charset changes there?
    Apologies again for the sheer newbness of the query.

  9. #9
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by invision2 View Post
    Right. I want to display the symbol, so I'll just use &pound; or & # 1 6 3 ; ?
    Correct.

    Quote Originally Posted by invision2 View Post
    Sorry to ask again, but will I lose my valid XHTML if I change charset? All the data is taken from a MySQL database - do I need to make any charset changes there?
    Apologies again for the sheer newbness of the query.
    I've never had to make any changes to the MySQL or SQLite configuration in order to make retrieved text display properly. As far as I'm concerned, UTF-8 creates issues that wouldn't exist if UTF-8 didn't exist.

  10. #10
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wicked. Thank you. Will let you know 9am GMT how successful it was

    Thanks again.

  11. #11
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by World Wide Weird View Post
    As far as I'm concerned, UTF-8 creates issues that wouldn't exist if UTF-8 didn't exist.
    Which alternative to UTF would you suggest should have been used to define a characterset to hold the hundreds of thousands of different characters where the most commonly used ones can fit in one byte, the next most commonly used in two bytes, and the least used in four bytes?
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  12. #12
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to save the file out again with a different character set if you are going to serve it as such.

  13. #13
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Which alternative to UTF would you suggest should have been used to define a characterset to hold the hundreds of thousands of different characters where the most commonly used ones can fit in one byte, the next most commonly used in two bytes, and the least used in four bytes?
    I don't concern myself with the inner workings of character sets at all, to be quite honest. If I see random characters in my text editor and/or Web page that I didn't type myself and then discover that they go away when I change character sets, that is what I do. That done, I forget about the annoying distraction and get on with whatever it was I was doing. I am simply not interested in making things more complicated than they have to be.


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
  •