Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
I've ran into some problems when reading strings from text files so I wrote a simple function to do it for me. Hopefully others will either find this useful or have a better way of doing it.
I've ran into some problems when reading strings from text files so I wrote a simple function to do it for me. Hopefully others will either find this useful or have a better way of doing it.
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
public static function ReadLine(data:ByteArray):String
{
var eol:Boolean = false; //eol = end of line
var str:String = "";
while (data.bytesAvailable > 0 && !eol)
{
var char:String = data.readUTFBytes(1);
if (char.charCodeAt(0) == '\n'.charCodeAt(0))
{
//Assert.AssertIf(false, str);
eol = true;
}
else if (char.charCodeAt(0) == '\r'.charCodeAt(0))
{
}
else
str += char;
}
return str;
}
Read more about:
BlogsYou May Also Like