I just got stuck trying to add a raquo (») to a submit button using hook_form_alter in Drupal.

I tried altering the text of the submit button as follows:

$form['submit']['#value'] = "Submit »";
$form['submit']['#value'] = "Submit »";

but both of these methods resulted in the ampersand being escaped in the HTML:

<input type="submit" value="Submit &amp;raquo;" />

So I eventually fixed this using unicode - so this post is really about using Unicode in PHP.

The unicode value for raquo is 0xC2 0xBB (c2bb), but you represent that in PHP in the following way:

$form['submit']['#value'] = "Submit \xC2\xBB";


« Back