Special Character when using the mailto: option
It's all about encoding.
£
is character number 0xA3
. This, when encoded "properly" (ie. in UTF-8), is converted to 0xC2A3
- coincidentally, you have the same A3
in there, which means the rendered result, £, looks like it just acquired a "random"  out of nowhere.
Solution: Encode the £
properly. Try £
first, and if that doesn't work try %A3
.
Html hyperlink body option in mailto does not support some special characters like '&'
You need to encode the entire url value after Subject=
with encodeURIComponent
.
If the subject contains HTML and/or urls themselves, then those also need to be encoded using encodeURI. Yes, this means 2 layers of encodeURIComponent for some parts.
const myLink = "http://localhost:5500/abc/def.html?did=" + value + "&title=" + encodeURIComponent(titlevar);
const body = encodeURIComponent('Click here to view my example: ' + myLink);
const emailstring = `mailto:?Subject=Sometext&body=${body}`;
The general issue is that you should always encode your strings when you are embedding them in a url. If that encoded string is embedded in another url, encode that too.
Passing special characters to mailto body blows up JavaScript
Mailto is a URI scheme so all of its components must be URI encoded. You can use JavaScript encodeURIComponent function to encode mailto components. Please see the following example:
function buildMailTo(address, subject, body) {
var strMail = 'mailto:' + encodeURIComponent(address)
+ '?subject=' + encodeURIComponent(subject)
+ '&body=' + encodeURIComponent(body);
return strMail;
}
var strTest = buildMailTo('abc@xyz.com', 'Foo&foo', 'Bar\nBar');
/* strTest should be "mailto:abc%40xyz.com?subject=Foo%26foo&body=Bar%0ABar" */
window.open(strTest);
Hope this help.
HTML mailto subject with '&'
You need to URL-encode the text; so it becomes:
<a href="mailto:no-one@snai1mai1.com?subject=free chocolate %26 cake&Body=get free hurry.">example
</a>
%26
is the Url-encoded representation of &
Mailto body, special characters?
have you tryed encoding the values with javascript?
eg
<a href="demo@email.com?subject='+encodeURI('emailSubject')+'&body='+encodeURI('emailBody')+'">
Set a mailto link with a subject containing an ampersand (&)
In order to get special/reserved characters into a URL, you must encode them - to get an &
to work, it must be encoded to %26
.
More details here: http://www.w3schools.com/tags/ref_urlencode.asp
Related Topics
How to Make Input Autofocus in Internet Explorer
Is There a Jdk Class to Do HTML Encoding (But Not Url Encoding)
Photoshop Mock Up Font Isn't Same as in HTML
Flexbox Layout with Two Equal Height Children, One Containing Nested Flexbox with Scrolling Content
HTML Tab Interface Using Only CSS
Change Text Color If Background Image Is Not White
Curved Lines Using Only HTML And/Or CSS
How to Specify Maxlength in CSS
Is 'Disabled' a Valid Attribute for an Anchor Tag
How to Conditionally Wrap Some Haml Content in a Tag
What's The Point of The <Option> "Label" Attribute Inside <Select>
In The Dom Are Node Ids Case Sensititve
Justify-Content: Space-Between Failing to Align Elements as Expected
Reset Particular Input Element in a HTML Form
Select Size Attribute Size Not Working in Chrome/Safari
Is The Copyright Meta Tag Valid in HTML5