FileStream.readMultiByte adds an extra carriage return to each line

I have a simple txt file named file1.txt that contains:

Line1
Line2

I have this code that reads the file and puts the content in the variable named str:

var file:File = File.applicationDirectory;
file = file.resolvePath("file1.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var str:String = fileStream.readMultiByte(file.size, File.systemCharset);
str = str.replace(/\n/g, File.lineEnding);
fileStream.close();
trace(str);

When I run this code, I get this:

Line1

Line2

(there are an additional empty line at the end of each line).

I've looked everywhere and I understand the text file created in Windows ads, a beginning of additional line after the end of line Flash interprets as extra line so I added recommended (see below) to convert end of line of devices... Any ideas how to solve this problem?

str = str.replace(/\n/g, File.lineEnding);

Maybe this works when you replace the regular expression with a string that contains "\n".

Tags: BlackBerry Developers

Similar Questions

  • Replace the carriage return or new line with a table space

    Hello

    I want to replace the carriage return or new line with space in my column of the database.

    To do this, I'm using this query:

    Select replace (replace (Comments, chr (10),' '), Chr (13),' ') OF Comments_Master

    Comments_Master is the name of the table and comments is column that contains carriage return or new line.

    But this query works as expected.

    Once I run this query and run the query again "select * FROM Comments_Master", transport return and new line still exist.

    Please let me know what is wrong with this query?

    You write that data back you? This example shows that your sql should work. I thinnk the query that you just described is the updated one below.

    create table blah (text varchar2 (100));

    insert into bla values (' it's multi)

    line of text ");"

    Select * from blah.

    Select replace (replace (text, chr (10),' '), Chr (13),' ') of bla.

    Update text bla = replace (replace (text, chr (10),' '), Chr (13),' ');

    Select * from blah.

  • How to concatenate a carriage return or new line to a variable of captivate?

    I need to provide to that further comments that captivate makes possible based on what users are doing questions.  I have this work for most, but I need to put comments for each question on a new line.  Captivate has resisted my efforts to get there.

    Any suggestions?

    Thanks in advance!

    OK, it does not work with the TextAreaWithVariables widget, but not the TextArea widget that comes with Captivate. And it does not add to the size of the file.

    Thank you, Steve, Lilybiti, and Jim, stick with me!

  • How can I add a page to my Web site which contains a list of items to sell? We must be able to add items, sort and delete? Each line item will have a video icon to see the points of sale.

    I am building a Web site for a cattle broker who needs to display cattle land for sale, which includes a description of the cattle (several bits of information) and a video of the cattle. It is a list that can be sorted by the key of the fields.

    Your experience of software development would say that you can pick up the necessary skills in HTML, XML, CSS, PHP, Javascript and RWD (Responsive Web design) required for a web developer. We look forward to provide any help you want.

    The aspect of the design of things will be to learn what appeals to users and what Google needs to rank your site well.

    Avoid the pitfalls of the Flash, the software and absolute positioning graphics never let write your HTML code for you.

    You will now be in a case sensitve * nix environment.

    You plan to generate your own graphics as well?

  • Write spreadsheet adds carriage return

    I use the array build function to set up a number of channels and build an array of strings.  The construction is in a time loop.  A new row is added in the table to each loop.  I use scripture to spread worksheet function to save the worksheet to a file with the xls extension.  For some reason, a carriage return is inserted in the table.  The table has 9 columns and a carriage return is placed after the fourth column.  I haven't added that carriage return.  Does anyone know why write about the spreadsheet can automatically add a carriage return, and how to remove it?

    Thank you!

    I'm not playing an instrument.  If the instrument is the addition of bottom line as a character of endpoint, which is likely, source your extra carriage return.

  • TextArea has double carriage returns

    I have an xml that looks like this

    < event >
    < event >
    Event < title > < /title >
    < description > This is the description of the event
    When I line breaks, like this
    the text box 2, everywhere
    I have only one.
    < / description >
    < / event >
    < / events >


    I even tried the tabs are, so that the extra characters only are CR LF, but I still see extra carriage returns in my textarea.

    Ayone know what is the cause?

    * The text box control uses UNIX style line endings, which means that text data containing Windows-style carriage return line feed (that is, \r\n) formatting for new lines contain extra line breaks. You can use the String.replace () with a regular expression to convert the text to type UNIX line purposes, as in the following example:

    windowsCRLF:RegExp = \r\n/gm private static const;

    ...

    myTextString = myTextString.replace (windowsCRLF, "\n");

    http://www.Adobe.com/support/documentation/en/Flex/2/releasenotes_flex2_sdk.html

  • The code formatting Pl/Sql with carriage returns

    According to the Guide (User Guide for the PL/SQL and reference page 2-2)
    It must be valid to use carriage returns for formatting:
    "To view the structure, you can separate the lines using carriage returns and withdrawal lines help
    spaces or tabs. This formatting makes the first IF statement more readable. »

    But I get an error when I try it.

    It seems as if there is no problem using line break, but I only have access to Oracle running under Windows.
    I'm looking for confirmation (by experience or inside knowledge),
    that is the case for all platforms (or at least Windows, Solaris and Linux)


    Test scenario
    select banner from v$version;
    BANNER
    ------------------------------------------------------------
    Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    
    5 rows selected.
    
    
    declare
      nl   varchar2(2) := chr(10);
      stmt varchar2(1000);
    begin
      stmt := 'begin' || nl
           || '  dbms_output.put_line(''Hello'');' || nl
           || 'end;';
      execute immediate stmt;
    end;
    /
    Hello
    
    PL/SQL procedure successfully completed.
    
    
    declare
      nl   varchar2(2) := chr(13) || chr(10);
      stmt varchar2(1000);
    begin
      stmt := 'begin' || nl
           || '  dbms_output.put_line(''Hello'');' || nl
           || 'end;';
      execute immediate stmt;
    end;
    /
    declare
    *
    ERROR at line 1:
    ORA-06550: line 1, column 6:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <en identifikator>
    <en identifikator, der er afgrµnset vha. dobbelte anf°rselstegn>
    <en tilknytningsvariabel> << close current delete fetch lock
    insert open rollback savepoint set sql execute commit forall
    merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 33:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <en identifikator>
    <en identifikator, der
    ORA-06512: at line 8
    
    
    Same error when using CR only
    
    Same error on 9i
    BANNER
    ------------------------------------------------------
    Oracle9i Release 9.2.0.6.0 - Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE    9.2.0.6.0       Production
    TNS for 32-bit Windows: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    
    5 rows selected.

    When you have tested 9.2.0.8 (Unix), it runs without problem when you used only a PMQ?

    Yes, no problem:

    SQL> select * from v$version where rownum = 1
    
    BANNER
    ----------------------------------------------------------------
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    1 row selected.
    SQL> declare
     nl varchar2(1) := chr(10);
    begin
      execute immediate  'begin ' || nl  || '  dbms_output.put_line(''Hello'');' || nl || 'end;';
    end;
    /
    Hello
    PL/SQL procedure successfully completed.
    
    but
    
    SQL> declare
     nl varchar2(1) := chr(13);
    begin
      execute immediate 'begin ' || nl  || '  dbms_output.put_line(''Hello'');' || nl || 'end;';
    end;
    /
    Error at line 13
    ORA-06550: line 1, column 7:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
       begin case declare exit for goto if loop mod null pragma
       raise return select update while with 
         <<
       close current delete fetch lock insert open rollback
       savepoint set sql execute commit forall merge
        pipe
    The symbol "" was ignored.
    ORA-06550: line 1, column 40:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    
       begin case declare end exception exit for goto if loop mod
       null pragma raise return select update while with
        
    
  • To add a carriage return in paragraph styles

    Hello. I'm a mess. I have a large amount of data from an xml source. I need to quickly add carriage returns properly across it so that paragraph styles can be differentiated. I use tags manually mapped to styles to do this.

    In the transport order returns am I right to think that I can add a GREP style for each style of Pará, and that it will be the direction of the end of Pará through the position of end of each tag marker? If that's the case, what GREP expressionlook would like that I can automate locate the end of a tag/para style so that I can add ~ b for her?

    With gratitude!

    [French]

  • Ability to add the carriage return character

    Hi all

    I have to add the characters return at the end of each paragraph.  I found insertTextAsContent (using: {String |}) SpecialCharacters} ( position: XMLElementPosition), but do not know how to use this function. I think that in this method only accepts the position as an XML element.

    How to use this feature to accomplish my task?

    Use: InDesign CS4/Javascript/Windows.

    Kind regards

    Karpanai

    you could do: string = "\r";

    \r is a carriage return, and \n is a newline

  • Add a carriage return in an alert box

    Hello

    I have a request for the user to display this alert box in the format below:

    ATTENTION: The owner's name has changed on this ship.
    Current name: xxxxxxx:
    New name: yyyyyyy

    Please confirm or deny that there is a change of ownership.

    Confirm and Deny are two buttons.

    How can I insert a distribution c return at the end of each line of text to the text looks so in the alert box? I can get it to wrap, but it doesn't look good
    the button "Confirm" and "Deny" is adjustable in different colors?

    Thank you!

    Use Chr (10).

    For example:
    v_alert: = "Attention: the owner's name has changed on this ship.' |" Chr (10) | ' Current name: ' | etc...

  • Carriage returns in the HTML Code, creating additional spaces between elements

    I looked everywhere online and cannot find the solution to my problem. I found several pages explaining a similar event, but no solution.

    When you put several divs side by side, I would like to visually display the code as a div by line: (see image) to do this, I have to use returns in my code (this method makes editing much easier visually). But doing so adds an extra space between the divs that turns a game of 3 columns of thumbnails to 2 columns. I can fix it if I adjust the physical margins between the divs, but this isn't the only solution.

    with-carriage-returns.jpg

    The other difficulty is that if I put the code back to back to back (see picture): what makes the div behave and appear as they should, but now the code is a Visual disorder because it is very crowded.

    no-carriage-returns.jpg

    What I want is to be able to use as many carriage returns in my code and for browsers to ignore these types of line breaks in the code. So, basically, how can I get away from these extra spaces when you use returns in the code?

    I think that your two pages have a missing at the end somewhere.

    OPPS... it happened when I was stripping down the page to create a working example of my question. I set the div missing and re-uploaded both pages. The problem is still there.

    Change display: inline; float: left; and add margin: 0 0 4px 4px; (as shown below)

    I had already tried to use floats, but something else in the code forced the columns to 2 instead of 3.

    'Apply Source Formatting' did you use?

    I use that religiously. I'm quite anal about visually clean code.

    Well, I just fixed the problem while responding... funny... I removed the margins of the element img real (.imageThumb img) and placed on the div that surrounds the img (.imageThumb). I also reapply the float. Thank you all for the help - it helped me rethink. But I could have sworn I had once placed the margins on .imageThumb before and it didn't work.

    {.imageThumb}

    Width: 100px;

    height: 75px;

    display: inline;

    float: left;

    margin: 0px 10px 10px 0px;

    cursor: pointer;

    }

    .imageThumb img {}

    / * margin: 0px 10px 10px 0px; * /

    }

  • CSR1000v - Extra return in telnet line/transport

    I'm running a weird question with a few CSR1000v routers circula 5.1 ESXi.  I created 10 virtual machines and of these 10 cases, I have 1 router which seems if insert an extra line (or a carriage return) in the CLI whenever I hit him "enter."  This question followed between SecureCRT and PuTTY.  I am also unable to use the "tab" key, upward or down arrows for the history and the '?' does not exit until I hit "enter".  Some examples follow:

    Router >
    Router > en
    en
    Router #.
    Router #.

    Arrow:

    Router #^ [[has

    Arrow:

    Router #^ [[B

    Tab key:

    Router > ^ I

    I am using the 'serial console platform' configuration and telnet to my ESXi server with port number address, IE: 172.100.100.2:2003 for Router3.  If I telnet between my routers (R1 telnets to an IP address on the interface of the CSR), the issue does not follow.  However, now that I have create my VM 11th and 12th, I see the extra line in the sessions during the series of console output.

    Anyone ever encountered this before?

    Good news!  Mark as resolved for others to find.  Kevin

  • Why does my re-installed Acrobat print codes hidden carriage returns?

    I worked happily with Adobe Acrobat for several years. Now, I had to buy a new computer and re - install Acrobat it is not working properly. Here are the facts: my old computer has Windows 7, my new computer has Windows 10. My version of Acrobat's Adobe Acrobat 9 Standard that I bought in 2010. It seems to be 32-bit, but I was not asked for a 64-bit version. The errors are:

    (1) when it creates the PDF the timeline saying wait for me because it is reading never goes away when the green line comes to the end.

    (2) when I opened the new pdf that I find some (not all) hidden codes that appear on my pdfs, for example carriage returns and codes related to the creation of boxes.

    (3) when I try again to create a pdf file, I get a different type of chronology which continues to repeat on the reading process.

    (4) I can not open then the new pdf until I have cancel the chronology of reading and if I then open the new PDF program locks up, producing an Acrobat screen with nothing visible on it, and I can't close the program.

    Okay, I think that there are several different things going on here.

    We would never call this last thing, a crash - this is when Acrobat disappears unexpectedly. We call cela a blockage, if Acrobat does not respond, or - if the answer but simply display a blank like that - something weird!

    But there are several different issues here. Let us look at the extra paragraph marks. Please print a page of the editor on your own printer. You see the same notes on paper?

  • Delete tagged text carriage return

    Hello

    I'm trying to score a few points, but I have some difficulty. I would like to mark all paragraphs of a textframe.

    I do it like this and works like its supposed to:

    var paragraphs:Array = indesignTools.getParagraphsForTextFrame(currentTextframe.id);
    
    for (var j:uint = 0 ; j < paragraphs.length ; j++) {
        var currentParargraph:Paragraph = paragraphs[j];
        if (currentParargraph.isValid) {
            InDesign.app.activeDocument.xmlElements.add("section", currentParagraph);
        }
    }
    

    Now, the problem I have is that, if the paragraph has a cart at the end, this carriage return should not get tag,

    so I should finish with a paragraph labeled, NOT to mention the last return transport.

    How do I change my code if I can mark all paragraphs without the last carriage return?

    Still waiting for a few comments of thanks or a useful on the post on the recovery of the properties of a "nil" style of characters but anyway...

    Why not just replace

    var currentParargraph:Paragraph = paragraphs[j];

    with something like

    var currentParargraph:Paragraph = paragraphs[j].characters.itemByRange(0,-2)

    It does not test, but should work.

    Don't forget to tell your little.

    Trevor

  • Carriage returns in Textarea field in the mail of the APEX

    Hi all
    I have a form that users fill out and when he clicks on submit uses APEX Mail to send the content to individuals in an HTML format. A field is a text box where the individual enters information like the example below:
    First to Arrive:  Bob
    Second to Arrive: Jane
    Third to Arrive: Sandy
    Last to Arrive: Fred
    When the message is received, instead of on a single line, each entry follows another as:

    First to arrive: Bob second to arrive: third arrived Jane: Sandy last to arrive: Fred

    I posted to get the fields of the form to show carriage returns and that works very well. Now, trying to figure what to add in order to make sure that this line breaks are like html br tags broken handles. Any help and examples would be appreciated.

    Thank you
    Wally

    Published by: wfsteadman on February 17, 2011 16:49

    Use HTML elementpre in HTML mail to keep a space for formatting.

Maybe you are looking for