Umlauts in subscriber names (HOWTO)

As I would like to send some email campaigns in Germany, the first step is making sure I can display special characters in the recipient names. As a test, I've added myself as a subscriber (via the web interface) with an umlaut like so 'Dan Ackersön'.

But, invoking subscribersGetActive() in the CampaignMonitor-1_1_1.php class gives me the following XML results :

<?xml version="1.0" encoding="utf-8"?>
...
<Subscriber>
<EmailAddress>my.email@my.co</EmailAddress><Name>Dan Ackersön</Name>
<Date>2008-11-16 11:08:00</Date><State>Active</State><CustomFields />
</Subscriber>

Changing the name of this subscriber to 'Dan Ackers&ouml;n' in the web interface returns the expected

<Name>Dan Ackersön</Name>
dackerson dackerson, 8 years ago

Using the subscriberAddAndResubscribe() method of CampaignMonitor-1_1_1.php:

$email = 'john@ray.do';
$name = 'Jöhn';
$result = $cm->subscriberAddAndResubscribe( $email, $name, $list_id );

fails silently (perhaps even a local php parsing error??).

Whereas:

$email = 'john@ray.do';
$name = 'J&ouml;hn';
$result = $cm->subscriberAddAndResubscribe( $email, $name, $list_id );

works as expected and successfully adds 'Jöhn' to the subscriber list.

Ken Ken, 8 years ago

Hi,

I think the problem is with how CampaignMonitor-1_1_1.php handles the encoded characters. When you use the API methods from here, the umlaut is preserved.

If you want to post you code here (remember to remove your API_KEY and ListID), we can have a look at it for you.


http://www.campaignmonitor.com
dackerson dackerson, 8 years ago

Definitely a problem with the 'soap' version of the CampaignMonitor-1_1_1 library, because default GET works flawlessly with subscriber name 'Jöhn' (I would guess because of the successful, internal call of urlencode()).

'soap' mode makes use of htmlentities() however.

'Jöhn' results in following soap call:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <Subscriber.AddAndResubscribe xmlns="http://app.campaignmonitor.com/api/">
        <ApiKey>d9127cc10cad589f53af70de60f3f114aad5f6f1</ApiKey>
        <ListID>470760</ListID>
        <Email>john22@ray.do</Email>
        <Name>J&Atilde;&para;hn</Name>
    </Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>

Check out 'J&Atilde;&para;hn' - yuck! Campaign Monitor doesn't even send a response back.

Hand-encoding 'J&ouml;hn' results in:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <Subscriber.AddAndResubscribe xmlns="http://app.campaignmonitor.com/api/">
        <ApiKey>d9127cc10cad589f53af70de60f3f114aad5f6f1</ApiKey>
        <ListID>470760</ListID>
        <Email>john22@ray.do</Email>
        <Name>J&amp;ouml;hn</Name>
    </Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>

The '&ouml;' is encoded to '&amp;ouml;' and Campaign Monitor accepts this.

If I replace CampaignMonitor-1_1_1.php's htmlentities() invocation with htmlspecialchars() and revert to 'Jöhn', I get :

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <Subscriber.AddAndResubscribe xmlns="http://app.campaignmonitor.com/api/">
        <ApiKey>d9127cc10cad589f53af70de60f3f114aad5f6f1</ApiKey>
        <ListID>470760</ListID>
        <Email>john22@ray.do</Email>
        <Name>Jöhn</Name>
    </Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>

Suprisingly, 'Jöhn' is just fine with Campaign Monitor (and correctly stores the subscriber name 'Jöhn').

Ken Ken, 8 years ago

Can you tell me how it behaves without using htmlentities() or htmlspecialchars(), and the text is passed along as is? ie Jöhn is unmodified?


http://www.campaignmonitor.com
dackerson dackerson, 8 years ago

Great idea! SOAP call (w/o any html*() encoding) worked fine with 'Jöhn':

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <Subscriber.AddAndResubscribe xmlns="http://app.campaignmonitor.com/api/">
        <ApiKey>d9127cc10cad589f53af70de60f3f114aad5f6f1</ApiKey>
        <ListID>470760</ListID>
        <Email>john22@ray.do</Email>
        <Name>Jöhn</Name>
    </Subscriber.AddAndResubscribe>
</soap:Body>
</soap:Envelope>

So, it seems that htmlspecialchars() really doesn't do anything at all.

Going a step further, I tried out some XML entity encoding 'J&#xF6;hn' with the original CampaignMonitor-1_1_1.php code (which uses htmlentities()). This worked just fine.

Ken Ken, 8 years ago

Great! I'm glad it worked.


http://www.campaignmonitor.com

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098