InvoiceBerry Blog

Our thoughts & tips on small businesses, freelancers and sole traders

Charset UTF-8, Charset ISO-8859-1, the £ (Pound) sign, AJAX and Prototype…

Written by on April 18, 2011

We know everyone says to use UTF-8 as charset. But what happens when you can’t? When your web host won’t change it? When the client does not want it? Would you just prefer to use the good old ISO-8859-1?

Well then join the club. We have everything working on ISO-8859-1 and so far everything is perfect. By using this charset we support not only the pound sign (£), but also latin and French letters and German umlaut which are not supported by UTF-8.

But recently we found out that by posting a form on InvoiceBerry the pound sign (£) was not showing up the right way. Instead it showed up as £.

The problem is that even though we thought everything runs on ISO-8859-1, our AJAX did not. Our apache web server runs on the right charset. HTML, PHP, everything right. Everything has charset set as ISO-8859-1.

But Javascript / AJAX (Prototype) only works on UTF-8.

So we found a way around it:

  • First go to your prototype.js file
  • search for “encoding”
  • you will find a line saying:

[php]encoding:     ‘UTF-8’,[/php]

  • change it to:

[php]encoding:     ‘ISO-8859-1’,[/php]

But this is not the end of the problem as Prototype is using the functions encodeURIComponent and decodeURIComponent to encode and decode special characters in the text.

By replacing all the encodeURIComponent functions to escape functions and all the decodeURIComponent functions to unescape function we solved the problem.

Now your entire system runs on the charset ISO-8859-1 and the pound sign (£) will be displayed correctly.

Please leave a comment or e-mail us to let us know if you have any problems along your way. Or if you are in London, why not pop into our office in Silicon Roundabout.

Subscribe now

Get our weekly digest into your inbox!

Sign up to our weekly newsletter to receive the best freelancing and small business articles on InvoiceBerry.

Ready to start invoicing your clients with InvoiceBerry?

Sign up to our free trial account. No credit card required.

Sign Up Now
Don't leave us yet!

Subscribe to our weekly digest!

Sign up to our newsletter to receive our weekly email digest every Friday morning and read about the best freelancing and small business articles on InvoiceBerry.

Read previous post:
Graphic Designers send simple invoices with Invoiceberry

The graphic designers over at Cup of 3 Design have used Invoiceberry from the very beginning to create their invoices....

We use cookies to give you a better experience. Check out our privacy policy for more information.