diff --git a/README.md b/README.md
index 73ec4d7e0..15ee308c4 100644
--- a/README.md
+++ b/README.md
@@ -125,7 +125,7 @@ Library Documentation")
## Prerequisites
-* PHP >= 5.2.1
+* PHP >= 5.2.3
* The PHP JSON extension
## Reporting Issues
diff --git a/Services/Twilio/Twiml.php b/Services/Twilio/Twiml.php
index e8c7605cd..98ae77826 100644
--- a/Services/Twilio/Twiml.php
+++ b/Services/Twilio/Twiml.php
@@ -92,15 +92,13 @@ public function __call($verb, array $args)
* want to break their existing code by turning their &'s into
* &
*
- * So we end up with the following matrix:
+ * We also want to use numeric entities, not named entities so that we
+ * are fully compatible with XML
*
- * We want & to turn into & before passing to addChild
- * We want & to stay as & before passing to addChild
- *
- * The following line accomplishes the desired behavior.
+ * The following lines accomplishes the desired behavior.
*/
- $normalized = htmlentities($noun, null, null, false);
- //then escape it again
+ $decoded = html_entity_decode($noun, ENT_COMPAT, 'UTF-8');
+ $normalized = htmlspecialchars($decoded, ENT_COMPAT, 'UTF-8', false);
$child = empty($noun)
? $this->element->addChild(ucfirst($verb))
: $this->element->addChild(ucfirst($verb), $normalized);
diff --git a/tests/TwimlTest.php b/tests/TwimlTest.php
index 81f502dc4..d606bf706 100644
--- a/tests/TwimlTest.php
+++ b/tests/TwimlTest.php
@@ -47,6 +47,30 @@ public function testSayConvienceMethod() {
$this->assertXmlStringEqualsXmlString($expected, $r);
}
+ public function testSayUTF8() {
+ $r = new Services_Twilio_Twiml();
+ $r->say("é tü & må");
+ $expected = ''
+ . 'é tü & må';
+ $this->assertXmlStringEqualsXmlString($expected, $r);
+ }
+
+ public function testSayNamedEntities() {
+ $r = new Services_Twilio_Twiml();
+ $r->say("é tü & må");
+ $expected = ''
+ . 'é tü & må';
+ $this->assertXmlStringEqualsXmlString($expected, $r);
+ }
+
+ public function testSayNumericEntities() {
+ $r = new Services_Twilio_Twiml();
+ $r->say("é tü & må");
+ $expected = ''
+ . 'é tü & må';
+ $this->assertXmlStringEqualsXmlString($expected, $r);
+ }
+
public function testPlayBasic() {
$r = new Services_Twilio_Twiml();
$r->play("hello-monkey.mp3");