If I remember well, you need to use \par in the RTF document for specifying a new line.
Find and read the RTF specifications. It will help you to do more other things. Octavian ----- Original Message ----- From: "Raphael Stoeckli" <[EMAIL PROTECTED]> To: <perl-win32-gui-users@lists.sourceforge.net> Sent: Wednesday, November 05, 2008 10:05 PM Subject: [perl-win32-gui-users] Newlines disappearing in richedit(unicode-content) > Hi @ all > > I’m working on an program, that can handle Unicode-text in > richedit-fields. > The fields sets and gets the text using some modifications of the > richedit-field. These mods are also from this mailinglist. > > The problem is, that Newlines (\r\n) in strings (whether if it’s ASCII or > Unicode) seems to be wiped, when I put the string into the modified > richedit-field. > > I wrote a demo/test-program to show this behavior. You can get it here: > http://www.rabanti.ch/storage/rtf_utf_test.pl or > http://www.rabanti.ch/storage/rtf_utf_test.zip (if there is a problem with > the encoding, while downloading) > Anyhow I try to describe it abbreviated in this post. > > For saving Unicode-content into a string, I use these functions: > ------------------------------------- > sub WM_USER() {1024}; > sub EM_GETTEXTEX() {+WM_USER+94}; > sub GT_DEFAULT() {0}; > > sub get_unicode # takes the text out of the richedit-field > { > my $maxlen = 1024; > my $buffer = " " x $maxlen; > my $flags = GT_DEFAULT; > my $codepage = 1200; > my $struct = pack("LLIpp", $maxlen, $flags, $codepage, undef, undef); > my $address = pack("P20", $struct); > my $wparam = unpack("L", $address); > my $numTchar = $WIN -> re -> SendMessage(EM_GETTEXTEX, $wparam, > $buffer); # re is the richedit-field, $WIN the window-object > my $octets = substr($buffer, 0, ($numTchar*2)); > my $text = decode("UCS-2LE", $octets); > return($text); > } > ------------------------------------- > > This is the richedit-field (simplified): > > $RE = $WIN -> AddRichEdit( > -name => 're', > -size => [240, 80], > -pushstyle => WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_LEFT > | ES_MULTILINE, > ); > > ------------------------------------- > > I get the text out of the field like that: > $SAVE = &get_unicode; > > When I try to write the string back into the field, I use this function > and definition: > ------------------------------------- > our $RTF_PROLOG = '{\rtf1'; > > sub string2rtf # string-converter for RTF-handling > { > my @input = @_; > $input[0] =~ s/([^\x00-\x7F])/'\uc1\u'.((ord $1 < 32768)?ord $1 : > ord($1)-65536).'?'/eg; > return $input[0]; > } > ------------------------------------- > > I try to set the text like that: > $WIN -> re -> Text($RTF_PROLOG . string2rtf($SAVE) . '}'); > > The result is that all stored lines (in the string) appear on one single > line, without newlines. > The operation >> $input[0] =~ s/([^\x00-\x7F])/'\uc1\u'.((ord $1 < > 32768)?ord $1 : ord($1)-65536).'?'/eg; << seems to wipe the newlines. I > checked the converted strings. The newlines (\r\n) are still there, > nonetheless the richedit-field do not recognize them. If I use $WIN -> > re -> Text($SAVE), the Newlines are appearing, but the unicode is broken. > > I think it's something about a sent (respectively not sent) system-signal. > But I have at this time no plan about these things. > I tested it on a Win2K (SP4)- System and a XP (SP3)-System with win32::GUI > v1.06 and Activestate Perl v5.8.6.811 > > Can someone explain me this behavior, and get me a hint, how to correct > this? > > Many thanks in advance!... and much sorry for the bad English. > > Regards, > Raphael > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/