   the "\n" dilemma (linebreak) -reborn
  hiim parsing txt files and uses tables for data for objects/units/buildings in my game. I wanna insert linebreaks in the strings i read from txt file but doesnt know how.\ndoesnt work. The string just gets the chars \ and n<enter-key> does work but i cannot use it as it messes up the "tables" i have in my txt-files (there's a lot of entries so i need to keep it clear). Every entry has one line of data+strings in the txt-file so i cannot use the enter key to tell it where in my strings i want a new line.Thanks for any helpErik   
  Did you try using \n and then manually replacing the \n sequence with a new line in your code after reading it from the file?   ;  im pretty bad with strings...There is no built-in functionality for this then?E   ;  You could probably use any character in the file that won't be used in the data. Replacing one character with '\n' is probably simpler than replacing a sequence of two characters.What language are you using in the first place?   ;Quote:Original post by sulimanim pretty bad with strings...There is no built-in functionality for this then?EYou can use std::string::replace(), at least if the only sequence you are interested in supporting "\n". If you want to be able to use support escaping quotes or other characters, you will need a bit more work.   ;  No, there is no 'built-in' functionality for this as what you want is arbitrary. You are going to have to either come up with a different way to seperate fields (such that linebreaks alone do not have any meaning other than to start a new line of text) or replace a sequence of characters with linebreaks after reading the data in (see above posts). One example of the former might be to have every entry terminated by a given character sequence (say "$\n", rather than "\n") so that a newline by itself is read in as normal. You would then likely want to read in the file as binary data rather than line by line to make things easier. The only real advantage to that is that editting the file by hand (ie. if these are descriptions of some sort) might be easier with a normal text editor. However, this will make it so it's harder to distinguish entries visually at first glance, but ideally if that's your goal, you may want to write a sort of 'resource editor' to do this more effectively (a very long line of text is not very pleasant to work with). If right now your main goal is making the implementation simple, you're probably better off simply representing linefeeds with some arbitrary character sequence and replacing it upon reading in the data.   ;  Is there anyway to read in the characters as binary data? You could just use 0x0D0A, 0x0D, or 0x0A depending on your preference. Or am I misunderstanding the problem?   ;  He's already using a new line as a delimiter.   ;  A wee bit tired, so I might be confused as to what the bloke wants, but here goes.Isn't he saying that the *characters* '\'+'n' are what're showing up when he *types them in*, and not '\n' like he is wanting?So isn't what he is wanting something along the lines of replace("\\n","\n") or somesuch?Or am I completely off mah rocker? <_<   ;  I think he is parsing out a text file and wants to read line breaks/new lines from the file for instanceHello there \nnext lineif parsed would output"Hello therenext line"but when he reads it from his file it outputs"Hello there \nnext line"