twilio/twilio-php — pull request #111 by Gipetto (2012-12-20 18:14:15+00:00)
Title: Fix special character support.

The current version of the Twilio PHP library will take input passed in and run it through the PHP `htmlentities` function. This produces "named" character entities in the output. Named character entities and XML don't get along. Only the 'quot', 'amp', 'apos', 'lt', and 'gt' entities are defined.

This change replaces the `htmlentities` call with an process that decodes the input and then runs it through `htmlspecialchars` to produce "numeric" entities instead.

This should accommodate most western character sets. Non standard (to htmlspecialchars) multi-byte character sets will fail silently in Twilio (ie: say nothing) instead of throwing an application error.

## Desired text

é tü & må

## Old and busted

Twilio returns "An application error has occurred" with the actual logged error being "Error on line 2 of document : The entity "Atilde" was referenced, but not declared. Please ensure that the response body is a valid XML document."

Ã© tÃ¼ & mÃ¥

## New Hotness

Twilio properly pronounces the characters.

é tü & må

## Test

The unit tests have been updated to test for desired output, but here's a quick test that can be run to observe the output:

say($line);
}

# All 3 say verbs in response should match
echo $response;

## New Requirements

Library now requires PHP 5.2.3 (formerly 5.2.1) to support the non-double encoding flag on the php function `htmlspecialchars`