Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Jazz00006 on October 08, 2006, 12:19:16 AM

Title: Writing to a file, will not create new line.
Post by: Jazz00006 on October 08, 2006, 12:19:16 AM
I know it doesnt seem like this belongs here, but is there a way to do this using code? I have no idea how, (or if changing the encoding type changes anything)

would making a different font change anything?

thanks for any help or info

EDIT: Subject change
Title: Re: Showing non-default characters
Post by: Llorean on October 08, 2006, 12:23:59 AM
I think you should maybe clarify further what you're trying to do. I don't exactly know what you're asking.
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 08, 2006, 02:00:46 AM
well, some characters, such as É or ü, do not show up when viewing them through the viewer or a print function in code.

is there anyway to make ALL of them show, or is this not possible yet.
and as above, is this possible through code? or will i have to make my own font to make them show
Title: Re: Showing non-default characters
Post by: Llorean on October 08, 2006, 02:13:07 AM
They should show up as long as you're using a font that supports them. For example, have you tried Unifont?
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 08, 2006, 02:18:47 AM
Thanks, i will give it a try, i will post back with my results ^.^
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 08, 2006, 10:43:28 PM
i have tried using code

rb->lcd_setfont("Unifont");

or other similar ones, rb->lcd_setfont(Unifont); , rb->lcd_setfont(Font_Unifont);

but it gives me a small error, any ideas on this?
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 14, 2006, 04:30:26 AM
^^ dont worry about the above, new question

how would i write to a file, but with each write, make a new line? (I am only having trouble with the new line part)


In my file i have something similar to

Code: [Select]
fd = rb->open(Temp_Data,O_RDWR | O_CREAT);

while(rb->read_line(file,buffer1,100) != NULL)
{
   char* pos =  rb->strcasestr(buffer1,word);
   if(pos != 0)    
   {
        rb->fdprintf(fd, buffer1, sizeof(buffer1));
rb->yield();
   }
}


rb->close(fd);

but with every time it does a search and write it only writes continusly, no gaps or spaces, only continous words.


Any help will be greatly apreciated, thankyou
Title: Re: Showing non-default characters
Post by: bluebrother on October 14, 2006, 07:26:55 AM
Code: [Select]
fd = rb->open(Temp_Data,O_RDWR | O_CREAT);

while(rb->read_line(file,buffer1,100) != NULL)
{
   char* pos =  rb->strcasestr(buffer1,word);
   if(pos != 0)   
   {
        rb->fdprintf(fd, buffer1, sizeof(buffer1));
rb->yield();
   }
}


rb->close(fd);

fdprintf prints a formatted text, so you need a formatter string. Why don't you use write instead?
Code: [Select]
rb->write(fd, buffer, sizeof(buffer));
should do it. You may also want to write only the amount of bytes read by read_line.
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 15, 2006, 07:01:26 PM
nope, that still gives me continous text,
heres a sample of what i get from it.

#!Translate Output File###Searching for: window                                                                              ###==Begin File==# window: Fenster ühlen )  raße (f) ve]  - igkeit ie Kühe nach Hause kommen ..) ] ichkeit[Noun]        window: Fenster (n) n )  raße (f) ve]  - igkeit ie Kühe nach Hause kommen ..) ] ichkeit[Noun]        window glass: Fensterglas (n) (f) ve]

heres what i would like to see

#!Translate Output File#
#
#Searching for: window
#
#==Begin File==#
window: Fenster ühlen
window: Fenster (n)
window glass: Fensterglas (n) (f)


I understand some things are my fault, but the new line part isnt.

thanks for any help you wish to give
Title: Re: Showing non-default characters
Post by: bluebrother on October 16, 2006, 06:19:30 PM
nope, that still gives me continous text,
heres a sample of what i get from it.
You are using read_line. From the comments of the read_line function (in apps/misc.c) you can find that all line ending characters are stripped. So you either need to read the lines a different way or add a line ending character after each line you wrote.
Title: Re: Showing non-default characters
Post by: Jazz00006 on October 16, 2006, 06:26:31 PM
nope, that still gives me continous text,
heres a sample of what i get from it.
You are using read_line. From the comments of the read_line function (in apps/misc.c) you can find that all line ending characters are stripped. So you either need to read the lines a different way or add a line ending character after each line you wrote.

I think i understand what you mean, so...

how would i add a line ending char to each line i write then?
Title: Re: Writing to a file, will not create new line.
Post by: LinusN on October 17, 2006, 03:17:49 AM
Use fdprintf() and add the newline to the format string:

Code: [Select]
rb->fdprintf(fd, "%s\n", buffer);