Using raquo in a submit button using hook_form_alter
- 21st February 2011
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 &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";