Special characters in title don't render/display properly
Steps to reproduce the bug :
1. Create new article (node/add/article).
2. Enter Title with special characters like : You Know You’
3. Now Save.
4.Check Output of the created article for me output is same as Input You Know You’
I expect that drupal need to handle or decode the title field content.
For example:
1. If we use "â" then it should be "â".
2. If my title is You Know You’
then output/create title should be You Know You’
I fix this by using "decode_entities" on node validation before a node title is created or updated.
Is this right approach to fix this type of issue.??
Here, I want to know how drupal deal with special characters for title field.
Thanks
Kumar Rahul Sankrit
Comment | File | Size | Author |
---|---|---|---|
Output-Special-Charaters.png | 23.2 KB | rahul_sankrit | |
Title-Special-Charaters.png | 24.25 KB | rahul_sankrit |
Comments
Comment #2
anurag.s CreditAttribution: anurag.s as a volunteer and at Iksula commentedComment #3
MegaChriz CreditAttribution: MegaChriz at WebCoo commentedThis is not a bug. The title field is a plain text field, not a HTML field. Therefore anything you put in the title field will be taken literally.
Comment #4
virajrajankar CreditAttribution: virajrajankar as a volunteer and at Iksula commentedComment #5
virajrajankar CreditAttribution: virajrajankar as a volunteer and at Iksula commentedYou can use this function drupal_html_to_text($string, $allowed_tags = NULL) to remove special character from any string.
You will get the output of
You Know You’
to"You Know You’"
.You need to write hook_node_presave in your custom module to use "drupal_html_to_text()".
Example Code :
Create custom module and put below code.
Comment #6
rahul_sankrit CreditAttribution: rahul_sankrit commentedThis issue has been fixed so now i am closing.
Place this one:
Thank you all.
Comment #7
rahul_sankrit CreditAttribution: rahul_sankrit commentedComment #8
MegaChriz CreditAttribution: MegaChriz at WebCoo commented