From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nm24-vm9.bullet.mail.ir2.yahoo.com (nm24-vm9.bullet.mail.ir2.yahoo.com [212.82.97.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1597C1A1EC4 for ; Fri, 14 Oct 2016 00:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1476428613; bh=U9tVOBwo8LBYPFlyvmaGawPHore8+a334fZuAXBCR7g=; h=To:From:Subject:Date:In-Reply-To:References:From:Subject; b=pWfQqBFbJAxoSh+OL+8SOK0pr66FAbRRWtLqBBZ+xfGQrEw4GaiS/DpYEmwbSoDy/3TLIzQFMtrKMdOApZZ+0J3Q+pzjPmuzGHsjWJsYQLaEiAsuMDzC0ih23/C/0artcE5nxaELy1AuEv9wfT7YGmkF5gtKhcrG+QNOnSJ0eV5eVoMEh5I3wLr2cbZQb2oXcQpIPVNk30swCzamrC6xjN9HZsA4X4u6C4YDQBPwTH66ufZZ1+iHdqsCTCX0xgZC1dUmpVugCsEHmlIZt/ooImk0THVu5s0C3iJ/wBVMduYKtCAvqA4z7JK5Hn/bPdYlWg4G2L1LwXTZOdUqyIC3ow== Received: from [212.82.98.61] by nm24.bullet.mail.ir2.yahoo.com with NNFMP; 14 Oct 2016 07:03:33 -0000 Received: from [46.228.39.71] by tm14.bullet.mail.ir2.yahoo.com with NNFMP; 14 Oct 2016 07:03:33 -0000 Received: from [127.0.0.1] by smtp108.mail.ir2.yahoo.com with NNFMP; 14 Oct 2016 07:03:33 -0000 X-Yahoo-Newman-Id: 120632.90424.bm@smtp108.mail.ir2.yahoo.com Message-ID: <120632.90424.bm@smtp108.mail.ir2.yahoo.com> X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 6Ii67fUVM1lmWoz_8Rt8zMPAMYw2ne70D78T_1KW1LpqCqf w_hX5Mz.zrshKbuEG290J97.PAHq.VWDjK2remjQzHBEVixjYT.PwInDyyZA YOt5.l_jcXb0Owcf7biyeqgBAI5BjRmu_9dcVMQHbXx8F1dO1fOphaAavEXB ZvpYELRyq_o79988JUgxX8E_1yKXxw1vbY2y1ZCN81AWsgb2FPKy0dwDu9aA O6S8LqMPaaM7SiLEoagMinhbx3.5UOMMGfPPyIK3NmZy3SU9170vTNiYSpCO A.sffXjHnB_XsacupVAFqA1AkmqgLp_FB44rC4BMTciZy_mPKlxCWqXqbnLn 5nwFKnLWoACgCrcDePYOxtHgVfBFjb7WMgGk3mXzb8w4ircnNyzlfDSnzdFp v.uvOhvrmoI2tD21ZuAiHdAeM4lbcBq1fpYjU9sikkgBrIahOPOWXcYMrdS. 8jTgG6geVjePaRc.EAQsVQ8RsXDCP28sg0P0egtoAOxy6vSIXZ.HIO4zPTbw WNxo.rat4w9hqF.lOf7FSfGZmuN3mcuemtHrHUlTTLXv8nGTQ0uEenT8NcP6 3eQ-- X-Yahoo-SMTP: zdtFpvyswBCD9kvh5aCgUNIYRGdRvNPFNNvAIw5Nvu4- MIME-Version: 1.0 To: Tim Lewis , "Gao, Liming" , edk2-devel-01 From: Joaquin Cono Bolillo Date: Fri, 14 Oct 2016 09:03:35 +0200 Importance: normal X-Priority: 3 Thread-Topic: AsciiPrint behavior with \n linefeed characters. In-Reply-To: <7236196A5DF6C040855A6D96F556A53F3F6968@msmail.insydesw.com.tw> References: <7236196A5DF6C040855A6D96F556A53F3F67FD@msmail.insydesw.com.tw> <4A89E2EF3DFEDB4C8BFDE51014F606A14B492FE6@shsmsx102.ccr.corp.intel.com> <7236196A5DF6C040855A6D96F556A53F3F6968@msmail.insydesw.com.tw> X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: AsciiPrint behavior with \n linefeed characters. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 07:03:35 -0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable In theory, and in =E2=80=9CStandard C=E2=80=9D-implementations, the fwrite(= )=E2=80=94related functions does the conversations in the =E2=80=9Cinternal=E2=80=9D FILE* -- buffer (in userland). The translation is done if the so called =E2=80=9Cstream=E2=80=9D, that is =E2=80=A2 file on disk =E2=80=A2 terminal =E2=80=A2 printer =E2=80=A2 NULL =E2=80=A2 something else, that is handled by the fopen()/fclose()/fread()/f= write() related functions was opened in TEXT MODE, and if the string is written to the internal FILE*= buffer by inserting additional CR before LF, or if read from the internal FILE *buffer, by removing each CR, that is suc= ceeded by LF With PC =E2=80=93 C =E2=80=93 Compilers/Libraries different algorithms are = implemented (only fread() examined): =E2=80=A2 WATCOM: the character following carriage return CR/0x0D is skippe= d,=20 If there are consecutive CR, the second one is available in the text buffe= r =E2=80=A2 Mircosoft: In a CRLF (0x0D,0x0A) pair, the CR is deleted in the = text buffer, otherwise it is copied to the textbuffer =E2=80=A2 Borland: each CR is removed =E2=80=A2 Digital Mars: each CR is removed In binary view you can see the differences, with that sample program #include int main(int argc,char **argv){ FILE *fp =3D fopen("test.bin","wb" /*open for binary write*/); //FILE *fp =3D fopen("test.bin","w" /*open for text write*/); fwrite("line1\nline2\nline3\n",1,sizeof("line1\nline2\nline3\n"),fp); fclose(fp); return 0; } The translation has to be done by the output function. To sure always use CR,LF in your string. Regards, JC Von: Tim Lewis Gesendet: Friday, October 14, 2016 04:05 AM An: Gao, Liming; edk2-devel-01 Betreff: Re: [edk2] AsciiPrint behavior with \n linefeed characters. Liming -- And I agree that this should be the behavior. I was surprised by the lack o= f translation for the other string printed via %s. Tim -----Original Message----- From: Gao, Liming [mailto:liming.gao@intel.com]=20 Sent: Thursday, October 13, 2016 6:24 PM To: Tim Lewis ; edk2-devel-01 Subject: RE: AsciiPrint behavior with \n linefeed characters. Tim: The first parameter in AsciiPrint() is the Format string. Per PrintLib.h = definition, \n will be changed to \r\n in the format string.=20 The following end of line(EOL) translations must be performed on the conten= ts of the format string: - '\\r' is translated to '\\r' - '\\r\\n' is translated to '\\r\\n' - '\\n' is translated to '\\r\\n'=20 - '\\n\\r' is translated to '\\r\\n' Thanks Liming -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Tim = Lewis Sent: Friday, October 14, 2016 5:29 AM To: edk2-devel-01 Subject: [edk2] AsciiPrint behavior with \n linefeed characters. In using AsciiPrint (I'm presuming the behavior is also in Print, but I hav= en't tested), I found an interesting behavior for linefeed characters embed= ded in strings that are parameters. I post it here just so people who are m= ystified by their output can understand it. Consider this example: CONST CHAR16 *XyzStr =3D "HI\nBYE"; AsciiPrint(XyzStr); AsciiPrint("Offset\n%s\n", XyzStr); Output looks like this: HI BYE Offset HI BYE It turns out that \n characters in the format string are converted to \r\n,= but \n characters in strings that are embedded (as in the second example) = are not converted. So only the linefeed character is interpreted, leading t= o "BYE" being suspended one character to the right and one row lower than "= HI" _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel