Covert a String to a TextStream?
BlitzMax Forums/BlitzMax Programming/Covert a String to a TextStream?
| ||
that's it, any idea if there's an easy and fast way to do this? |
| ||
Hi, Not currently - what's really needed is a TStringStream. May have a go at this today. |
| ||
I've managed to make it this way:Local Str:String = "String to convert to a stream~nof thow lines" Global T:TTextStream = New TTextStream Local DataStream:TStream = CreateBankStream(New TBank) T = TTextStream.Create(DataStream, TTextStream.UTF16LE) T.WriteString(str) T.Seek(0) While not T.Eof() Print T.ReadLine() WEnd Obviously a TStringStream would be incredible great. |
| ||
Sorry to come up with this old thread, but still no TStringStream or have i missed something? |
| ||
A RAM Stream points directly to a buffer/string. This is faster than the option above since there's no copying involved.Local str:String Local stream:TStream str = "this is a test" stream = CreateRamStream(str, str.length, True, False) Print stream.ReadString(5) But careful with that, writing beyond the length of the stream will cause problems. |
| ||
This is faster than the option above since there's no copying involved. Just what i was looking for, thanks! |