Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Character sets and the GBP symbol

    Hi all,

    I was having a bit of a problem properly displaying the GBP symbol (£) in some tax calculators I created.

    Basically the user types their entries and the answer is presented in a form text field with a preceeding £ sign. This works on every server I've installed it so far until today. For some reason the £ is being replaced with a ? on both IE and FF.

    I double and triple checked my script and nothing worked. I then tried just doing:
    Code:
    <script type="text/javascript">
    alert("£");
    </script>
    And even this doesn't work. Upon further investigation it seems the server is set to use UTF-8 character encoding whereas all the other servers are using iso-8859-1. To test my theory that this was causing the problem, I created the following script on my local machine:
    Code:
    <html>
    	<head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    	</head>
    	<body>
    		<script type="text/javascript">
    			alert("£");
    		</script>
    	</body>
    </html>
    And I get the same problem. So it seems that the issue is the UTF-8 character set, but I don't understand why - I thought iso-8859-1 was a subset of UTF-8 and anything that worked in iso-8859-1 should therefore work in UTF-8?

    Since there's no chance of me getting the admin to change the server config (I can't even do it via .htaccess, I tried), does anyone know a workaround for this problem? I tried using the character codes &#163; and &#xA3; and I also tried using &pound; but the problem is when these are echoed to the text field they appear as they are typed instead of appearing as a £ symbol.

    Anyone have any ideas?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    alert('\u00A3')

    this is the way javascript handle unicode characters. '\uhexaval'

    and should work without specify the unicode charset if dealing with HTML...i guess... It works for me on a simple charset=iso-8859-1.
    Last edited by Kor; 08-16-2005 at 05:30 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works perfectly, thanks Kor

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    You're welcome... Even I don't know if you like Manchester United team as I do...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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