# Anything special about '

**URL:** <https://discourse.softpress.com/t/anything-special-about/10600>\
**Category:** Dynamo\
**Created:** [March 31, 2011, 1:49pm UTC](https://discourse.softpress.com/t/anything-special-about/10600 "2011-03-31T13:49:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.ledger](https://discourse.softpress.com/user_avatar/discourse.softpress.com/david.ledger/32/53_2.png) [@david.ledger](https://discourse.softpress.com/u/david.ledger)\
**Post date:** [March 31, 2011, 1:49pm UTC](https://discourse.softpress.com/t/anything-special-about/10600/1 "2011-03-31T13:49:55Z")

</div>



---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [March 31, 2011, 2:06pm UTC](https://discourse.softpress.com/t/anything-special-about/10600/2 "2011-03-31T14:06:53Z")

</div>

Ajax transactions, by fiat, are all conducted in UTF-8 Unicode. Web  
pages may or may not be encoded that way, and it does take some  
coercion to get PHP to do this. If you are getting your data out of  
MySQL, then check to see which encoding the table and column are in.

I make a habit of forcing all of my databases to UTF-8, and add the  
following set of belt-and-suspenders shims to enforce the correct  
behavior in PHP/MySQL. Also, use a text editor that allows you to  
choose your encoding, and make sure all of your PHP is actually  
written in UTF-8. For some reason, this helps.

//put this before anything else in all your PHP  
mb\_internal\_encoding(“utf-8”);

//Issue the following query before each request of the database  
//(I’m using MyActiveRecord, but just make sure the query gets sent  
somehow)  
MyActiveRecord::Query(‘SET CHARACTER SET utf8’);

If you can wait that long, PHP6 is supposed to be entirely Unicode-  
clean and everything will run in UTF-8 out of the “box”.

If you’re mixing your hand-coded (Unicode) PHP into a Freeway layout,  
then check to be sure that Freeway is actually encoding your page in  
UTF-8. ‘Automatic’ is supposed to equal UTF-8, but I have seen it do  
other things besides that. Setting the page encoding to Unicode will  
definitely do the right thing.

Walter

On Mar 31, 2011, at 9:49 AM, David Ledger wrote:

> I’m working with a list of alternative fabric ranges as options to  
> chairs in PHP. Because the different ranges cost differently I’m  
> adding the incremental prices as strings to the ends names of the  
> fabric ranges in a popup list.  
> So a range might be presented as  
> Stirling Tweed (+ £1.45)
> 
> The problem is that when I refresh the page this shows as  
> Stirling Tweed (+ Â£1.45)
> 
> - that’s (cap A circumflex) (UK pound)  
> but if I do an Ajax refresh of the div containing the popup it is  
> correct.
> 
> It is getting put through urlencode() but as far as I can see this  
> generates %C2%A3 which looks like unicode but I don’t know how to  
> check if it’s unicode for UK pound without searching though the  
> thousands of table entries.
> 
> As character entities, %C2 is Â (cap A circumflex) and %A3 is £ (UK  
> pound) so it looks like I’m getting my encodings mixed somewhere.
> 
> Anyone know what to look for?
> 
> David
> 
> –  
> David Ledger - Freelance Unix Sysadmin in the UK.  
> HP-UX specialist of hpUG technical user group ([www.hpug.org.uk](http://www.hpug.org.uk))  
> email@hidden  
> [www.ivdcs.co.uk](http://www.ivdcs.co.uk)
> 
> * * *
> 
> dynamo mailing list  
> email@hidden  
> Update your subscriptions at:  
> [http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

* * *

dynamo mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)
