forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LuaPlayer "bug".

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Mon Jul 10, 2006 7:37 am    Post subject: LuaPlayer "bug". Reply with quote

Whenever the character "\0" is in a string, and it is displayed, nothing after it is displayed. For example:

local s = "first" .. "\0" .. "second"
screen:print(0, 0, "s", Color.new(0, 0, 0))

It will only display "first".

I haven't actually tested the above. However, I have io.read files with the \0 character into a variable, and the same effect occurs. I am not sure if the bug is with reading files or displaying strings.

I'm sure I'll get a snarky reply saying it's supposed to do that, but the newline character doesn't do what it's supposed to, making it a stupid thing to say.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon Jul 10, 2006 8:48 am    Post subject: Reply with quote

It's supposed to do that... null termination :P
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Mon Jul 10, 2006 6:10 pm    Post subject: Reply with quote

*shakes fist*

It may be, but I can't avoid it without modifying the string.
Back to top
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Mon Jul 10, 2006 9:34 pm    Post subject: Reply with quote

Take a look at the serial port example in Lua Player for a full terminal simulation with newline and scrolling.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Tue Jul 11, 2006 6:55 am    Post subject: Reply with quote

You'll either have to modify the string or treat the data differently.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Thu Jul 13, 2006 6:00 am    Post subject: Reply with quote

in c the \0 is to signify the end of the entire string. LUA is useing the same format.
Back to top
View user's profile Send private message
SSpeare



Joined: 23 May 2006
Posts: 63

PostPosted: Thu Jul 13, 2006 6:13 am    Post subject: Reply with quote

romero126 wrote:
in c the \0 is to signify the end of the entire string. LUA is useing the same format.


Actually, Lua uses 32-bit clean strings. It is legal to put '\0' character into a Lua string. It will not terminate the string and it will still report the correct string length. The problem occurs when you send that string over to C and some C code assumes that '\0' terminates the string.

In the end, any string code should probably assume that '\0' will terminate the string, even though in Lua it actually won't.
Back to top
View user's profile Send private message Visit poster's website
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Thu Jul 13, 2006 6:57 am    Post subject: Reply with quote

SSphear you are absolutly right '\0' is used by c programmers as a char[] terminator to avoid any errors during output. The length still remains the same. Even the string behind char[] remains the same.

While the data is not lost. char[] simply overwrites the data up to a certain level. What that means is that you can also use \0 in c/c++ and it have the same result. However most interpreters use the \0 as an endall for their code.

When you work with strings in c/c++ this gets thrown out since the system uses a allocated char[] based array which is static to the total size of the string. (IE the string is dynamic in size) So when you call string.len (i forget the actual command) it calls the allocated memory for that string. Instead of the first \0.

Simple yet complicated. Hince the previous simplistic comment

"in c the \0 is to signify the end of the entire string. LUA is useing the same format."
Back to top
View user's profile Send private message
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Thu Jul 13, 2006 4:50 pm    Post subject: Reply with quote

It's a tedious matter to edit ID3v2 tags, as some have padding. I have to remove then re-insert the padding. Although that is possible and a reasonably easy task, it still seems better to at least give a setting to change how it works. I don't know. I guess I'll just put up with it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group