PR/CR/LF while parsing text...

I’m loading an array by importing a text file that’s encoded with Unicode (UTF-8) using a script that executes in edit mode:

@script ExecuteInEditMode ()

var gameController : GameController;
var infoData : TextAsset;
var infoArray : Info[];

function Start () {
		gameController.infoArray = InfoDataLoader();
}


function InfoDataLoader () {
	var infoDataText = infoData.text;
	var dynamicInfoArray = new Array ();
	
	var infos = infoDataText.Split("#"[0]);
	for (var info : String in infos) {
		var infoDetails = info.Split("|"[0]);
		
		currentInfo = new Info ();
		var tempINT : String = infoDetails[0].ToString();
		currentInfo.id = int.Parse(tempINT);
		tempINT = infoDetails[1].ToString();
		currentInfo.progress = int.Parse(tempINT);
		currentInfo.title = infoDetails[2].ToString();
		currentInfo.description = infoDetails[3].ToString();
		currentInfo.hint = infoDetails[4].ToString();
		currentInfo.summary = infoDetails[5].ToString();
		currentInfo.congratulations = infoDetails[6].ToString();
		tempINT = infoDetails[7].ToString();
		if (tempINT != "")
			currentInfo.nextInfo = int.Parse(tempINT);
		dynamicInfoArray.Push (currentInfo);
	}
	
    // Copy the js array into a builtin array
    infoArray = dynamicInfoArray.ToBuiltin(Info);
    
    //	To Check that the data has been pushed and copied to the final array
    for (var checkInfo : Info in infoArray) {
//    	Debug.Log ("ID: " + checkInfo.id + "  Title: " + checkInfo.title + "  Start Progress: " + checkInfo.progress + "\n\nDescription: " + checkInfo.description + "\n\nHint: " + checkInfo.hint + "\n\nSummary: " + checkInfo.summary + "\n\nCongratulations: " + checkInfo.congratulations + "\n\nNext Info: " + checkInfo.nextInfo);
    }
	
	return infoArray;
}

Works fine with the exception of the paragraph / carriage return / line feed. This method just seems to ignore them.

The text runs together at the pr/cr/lf. I’ve tried changing the line endings in unitron to all the other choices in the men (afaict). I tried changing the line ending to \n but it just printed \n as text.

Any hints or suggestions?

Are the line breaks failing to show elsewhere the game or in the Debug.Log calls?

No. Not that I’m aware of. I find that in Debug.Logs the \n indicator works fine.

I know that text is handled differently depending on context, in that if you use us \n in a Debug.Log it is handles as a line return, but if you put that in GUI Text, it’s treated and printed as the individual characters.

I had assumed that since I was importing text into a String variable, which seems to take normal keyboard as a cr/lf/orwhatever… that using the split function would just import them as well.

On the other hand, this could be an export/encoding problem as well.

I’m exporting the file as tab delineated text. When I look at the file in Unitron and turn “show invisible characters” on, there is the cr/lf and the appropriate white space, but no hard “P” paragraph return symbol. If I type paragraph returns in unitron, a hard “P” symbol appear and if I retype (or replace) this non-existent white space with unitron’s pr and white space, it seems to split properly with cr/lf’s.

Not sure what the issue is.

Right now my work around it to clean the file in Unitron by finding the first pr and hard typing it, then copying it into the replace window and then copying another white return into the find and doing a replace all with what is apparently nothing with nothing… but it’s a different type of nothing.

An extra step but it seems to work.