Readstring needs to know the length of the string

BlitzMax Forums/BlitzMax Programming/Readstring needs to know the length of the string

slenkar(Posted 2009) [#1]
I was trying to convert juicy fonts to blitzmax, it uses readstring at the beggining of a file but in blitzmax readstring needs to know the length.

How would I get the size of a string from a stream?


N(Posted 2009) [#2]
Read until you find a 0 byte/short, depending on how it's stored. By this point, however, you will have read all of the characters, so you don't need to know the length, you just need to read the string in a different way (one that treats it as a null-terminated string instead of as a string of N characters).


plash(Posted 2009) [#3]
How would I get the size of a string from a stream?
As Nilium said, you can use Null termination for string reading, or you can use length-included strings.

Some functions to do both approaches:



Blueapples(Posted 2010) [#4]
slenkar,

Did you ever get anywhere with converting the Juicy Fonts library to BlitzMax? I'm looking to use it in a project and it's a fair bit of code to convert. If you've already made progress I'd rather not redo all that work.


slenkar(Posted 2010) [#5]
i made my own instead,

it has no gui, you have to modify the code to change the font etc.

to display a font I used this code with my own version of max2d


you may be able to use animimage commands instead