|
|
mailto URL fails with "�"
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
I'm using the NSWorkspace openURL method and a "mailto:..." URL in my application to send an email message using the default email application (usually Mail.app).
Usually it works fine, however I've figured out that if the body part of the email message in the URL contains a "�" (degrees) character, the body of the email ends up being empty!
I've checked that the "CFURLCreateStringByAddingPercentEscapes" funtion is not doing anything bizarre, but it is translating the "�" into a "%B0" (which I assume is correct - even if it's not, why would it cause the entire message to be empty?).
The relevant bit's of my code are below. Does anyone have any idea why this is happening or how I can work around the problem?
Code:
subject = (NSString *)CFURLCreateStringByAddingPercentEscapes
(NULL, (CFStringRef)subject,
NULL, NULL, kCFStringEncodingISOLatin1);
body = (NSString *)CFURLCreateStringByAddingPercentEscapes
(NULL, (CFStringRef)mutableBody,
NULL, NULL, kCFStringEncodingISOLatin1);
escapedURLString = [NSString stringWithFormat:@"mailto:?subject=%@&body=%@",
subject,
body
];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:escapedURLString]];
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Just a quick follow up. I've just tried entering the following URL into Camino's URL field:
mailto:?subject=blah&body=blah�blah
and it works fine, including the "�". So why doesn't my code work?
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Okay, I've solved the initial problem by using UTF8 encoding instead of Latin encoding. This works fine for most characters. Along the way, I also changed to using NSString's "stringByAddingPercentEscapesUsingEncoding:" method instead of the core foundation function (because it's a lot easier to read).
However, I've now got a problem with "&" characters. It simply does not translate them.
I guess this is because "&" is perfectly legal in URL's (as GET argument seperators). I'll have to manually translate them to %-escapes myself.
(
Last edited by Brass; Nov 6, 2003 at 07:33 PM.
)
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Baleeted: screwed up on an entity, and then realized I didn't properly understand the problem! D'oh!
(
Last edited by Wevah; Nov 8, 2003 at 09:44 PM.
)
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|