I'm trying real hard to get a simple newline in an Email shown with Outlook which is sent with Cakephp's CakeEmail.
What I've tried so far:
<br/>
"\n"
"\n\n" (this strangely works but I get not 1 but 2 newlines everything else won't work)
"\r\n"
CakeEmail:emailFormat('text'); (with all of the above again, same result)
Any help would be appreciated. Been trying for an hour now. I'll bet those frakkin toasters got something to do with it.
Related
I am having some difficulty getting linebreaks to work for my Unity UI elements. (Unity 2019.2.17f1 Personal)
What I'm doing is:
string twoLinesOfText = LanguagePack.getTextByID(ID);
result:
twoLinesOfText = "Text line 1\nText line 2"
Expected output:
Text line 1
Text line 2
Reality:
Text line 1\nText line 2
I have tried using "\n", "\\n" and "\r\n". None of these give the intended result.
I assign the text to the component using
UITextComponent.GetComponent<Text>().text = twoLinesOfText;
Can this direct assignment be a problem? Do i need to push my string through a toString() or parse it somehow for the \n to be recognised?
Workaround:
I have a workaround. By using an XML file for my LanguagePack, and inserting (enter) linebreaks in the base file, I feed the linebreaks into my Unity UI elements. Obviously this is not ideal.
Reading back the strings in Debug.Log does not show which linebreak code was ultimately used: it just breaks the string according to the (enter) linebreaks in the XML file.
You can't import it trought Language Package. What you should do is :
string line1 = LanguagePackage.getTextByID(ID1);
string line2 = LanguagePackage.getTextByID(ID2);
string twoLinesOfText = line1 + "\n" + line2;
UITextComponent.GetComponent<Text>().text = twoLinesOfText;
Run into this problem myself, a little investigation showed that what I thought was \n in the string had been converted to \\n so it showed in the text box as \n.
Converting it during debugging to just \n got me the multiline text I wanted.
Now to investigate where in my data chain it got converted :-)
Ok, investigation complete. A file was saved, on my PC from a program in Visual Basic using the File.WriteAllLines function, one of those lines had a couple of instances of \n. A look at that file in notepad shows it had correctly written that line. The problem came when I used File.ReadAllLines in my unity program as it converted those \n instances to \\n. As far as I can tell this is not a documented action, in fact it's possible, on reading the MS docs, to think that it would have split that line into multiple lines, which it doesn't do.
I checked in my VB program and File.ReadAllLines does not behave in this way there. It's probably something to do with the environment, VB does not use \n, C# does. I fixed the problem by tagging a replace onto the string e.g. string.Replace("\\n", "\n"). It's entirely possible that attempting to write a string from C# with File.WriteAllLines could also mess with \n.
Geez, this was hard to write as the Editor here messes with \\n and convert it to \n and I end up having to use \\\n
For people who encounter this issue. You Could try to use some HTML similar syntax and see whether it works or not.
Eg:
Using for newline instead of \n
I'm trying to parse a web page that has non-printable characters on it and write that to a file in python. I'm using Python 2.7 with requests and Beautiful Soup.
I get the page with requests, and parse it with the following-
for option in recon:
data['opts'] = '/c' + option
print "Getting: ",
print option
r = requests.post(url, data)
print r.content
page = bs4.BeautifulSoup(r.content, "lxml", from_encoding='utf-8')
print page
tag = page.pre.contents
print tag[0]
When testing, the print r.content shows the page properly in all its unformatted glory. The page is a .cfm, and the text I'm looking for falls between "pre" tags. After running through bs though, bs interprets some of the non printable text into "br" tags, resulting in tags being a list of 2 items, instead of just all the text between the pre tags. Is there a way to either just get the text between the pre tags with requests, or do something differently with bs to get it to not misinterpret the characters?
I've read through the following trying to figure it out, plus requests and beautiful soup docs, but found no luck so far-
Joel on Software - Character Sets
SO utf-8 vs unicode
SO Getting text between tags
Overthought the problem. I just base64 encoded the data before transfer with certutil on windows, removed the first and last line, and then decoded on the far side.
I have a google form that gets generic information from the user and saves it all in a sheet. When a new form is submitted, the information is appended together with a new line (\n) command between every new piece of information, and is sent to an email using the Mailapp.sendEmail(email, subject, message) function. This works fine, and is formatted the way I would like it. However, when I use the Mailapp.sendEmail(email, replyEmail, subject, message) function, the \n commands seem to disappear from the code. They do not show up in the email and the information in the email is all grouped together in 1 line. Does anyone know why this might be happening, and how I would be able to get the formatting back? Thanks!
The email is formatted as html. If you change your '\n' to '<br>' it will break the lines.
This was my test:
MailApp.sendEmail("me#myDomain.org","test#example.com" , "Subject", "This<br>Is<br>The<br>Body");
I'm testing a program that I'm writing in perl to send automated emails by sending them to myself first and I am noticing that all the carriage returns and tabs (\n and \t) that I am putting in the emails are turning up in outlook as spaces when I read the emails. Any idea what could be going on here?
"\n" is a unix end of line
i think you need to use "\r\n" for windows
There is a feature in Outlook to discard the extra lines. The alert is hard to see in the message. It should be above the From line when you double-click and open the message.
It should say something like "Extra line breaks in this message were removed -> Restore line breaks"
To prevent this problem, try formatting your lines with a carriage return and line feed (\r\n) instead.
For starters, I would advise avoiding tab (\t) characters in email messages; there's no standardization among email clients controlling how they're displayed.
I'm trying to figure out how to encode newlines in the DESCRIPTION part of an iCal file in such a way that they will import properly into Outlook, Google Calendar and the Apple Calendar.
The original code I inherited used "=0D=0A" with a quoted-printable encoding, which works great in Outlook, but not in Google Calendar.
The spec seems to say you should use "\n" to represent a newline. This works great in Google Calendar, but Outlook just puts the literal "\n" characters in there.
Is there a way you've done this that will work consistently accross calendaring systems?
OK, looks like I'm answering my own question.
The correct way to do it is to use "\n" for line breaks. Outlook did not recognize this because I had "ENCODING=quoted-printable" on the description. Once I removed that, Outlook displayed the new lines correctly.
Also, to get the file to open correctly in Apple iCal, you need to use "VERSION:2.0" for the file version. If you use "VERSION:1.0", it will tell you it can't read the file (even though it conforms to the 1.0 spec).
NOTE: As others have mentioned, the file actually has to contain the literal string \n. Since most languages treat that as an escape sequence meaning a newline character, you probably need to use the string \\n in your code.
The comment with the link to the RFC from Matthew Bucket above in the original post helped me. Quoting from there:
A BACKSLASH character in a "TEXT" property value MUST
be escaped with another BACKSLASH character
So, I did a
$description = str_replace("\r\n", "\\n", $description);
and it worked
Might be worth saying that you need the literal \n, not the newline symbol, literally backslash then n in the ical. Also don't forget to do the 75 character "folding" too.
Your output file should be like below---
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//2013//#Ur Site Name#//EN
BEGIN:VEVENT
UID:[event]2012
DTSTART:20130101T100000
DTEND:20130101T120000
LOCATION:
SUMMARY:#Meeting Title here#
DESCRIPTION:What is realistic for financial services companies to achieve via Social Media channels? \n\nJoin us on 11th September 2013 at 4pm (BST) where we
-----bla bla bla ----
END:VEVENT
END:VCALENDAR
Here you have to take care of Version, it should be 2.0 and Escape char ... \n(newline), semicolon(;) and comma(,). If you are writing in .net then it should like ... "\\n", "\\;" and "\\,".
You can check your output file on this site as well... https://icalendar.org/validator.html
Thanks,
Bhaskar
According to this RFC:
Content lines are delimited by a line break,
which is a CRLF sequence (CR character followed by LF character).
So you should use \r\n. I used this in strings without additional backslash escaping.
This is my answer for DESCRIPTION
$filev = str_replace("\r\n", '\\n', $p);
$filev = str_replace("<br>",'\\n',$filev);
$filev = (str_replace(";","\;",str_replace(",",'\,',$filev)));
I had to escape the output in the string to set a literal "\n" in the output file. Like so. Worked a charm.
$events .= "DESCRIPTION:" . str_replace("\n","\\n",str_replace(";","\;",str_replace(",",'\,',get_event_contents()))) . "\n";
=0D=0A works with Outlook, but you'll need to change the DESCRIPTION key, so that line breaks can be interpreted.
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:
Enter your text after the colon, using =0D=0A for line breaks. Outlook will read the line breaks correctly. Using \\n only works if you're using DESCRIPTION without ENCODING:QUOTED-PRINTABLE.
I'm using VERSION:2.0