<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 10:42 AM, Brian Vuyk <span dir="ltr"><<a href="mailto:brian@brianvuyk.com">brian@brianvuyk.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all.<br>
<br>
I am having a bit of a unique problem here, and I am hoping someone can help me out.<br>
<br>
In short, we are outputting strings from a custom module we wrote to an external service that only accepts the ASCII character set. So, I am trying to run all the strings through iconv() to convert them.<br>
<br>
Here's the weird part. Take the script below:<br>
<br>
$string = "Stéphanie,D Hérouville";<br>
$output = iconv("UTF-8", 'ASCII//TRANSLIT', $string);<br>
print $output;<br>
<br>
If I run this from the command line, I get the proper output - 'Stephanie D Herouville'. However, if I run it in my Drupal installation, whether as part of a module or from the Devel 'Execute PHP' box, I get different output: 'St?phanie D H?rouville'. That is, instead of replacing the character with it's expected ASCII counterpart, it replaces it with a ?.<br>
<br>
Has anyone encountered this, or have any idea why this is happening?<br><font color="#888888">
<br>
Brian<br>
</font></blockquote></div><br><br>I confirm what you are seeing:<br><br>If you have a file called ascii.php with this in it:<br><br><?php<br>
$string = "Stéphanie,D Hérouville";<br>
$output = iconv("UTF-8", 'ASCII//TRANSLIT', $string);<br>
print $output . "\n";<br>
?><br>
<br>And run it as:<br><br>$ php ascii.php<br><br>
The output is without the accented characters.<br><br>However, if you boot Drupal first, like so:<br><br><?php<br>require_once './includes/bootstrap.inc';<br>drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);<br><br>$string = "Stéphanie,D Hérouville";<br>
$output = iconv("UTF-8", 'ASCII//TRANSLIT', $string);<br>print $output . "\n";<br>?><br><br>The output is with question marks, as you said.<br><br>I suspect something in includes/unicode.inc is causing this.<br>
-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com">2bits.com</a>, Inc.<br><a href="http://2bits.com">http://2bits.com</a><br>Drupal optimization, development, customization and consulting.<br>Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra<br>
Simplicity is the ultimate sophistication. -- Leonardo da Vinci<br>