[Gambas-user] Cannot Split() against ASCII NUL byte
Tobias Boege
taboege at ...626...
Mon Aug 5 18:31:40 CEST 2013
On Mon, 05 Aug 2013, Jim Provan wrote:
> On 08/05/2013 09:53 AM, Tobias Boege wrote:
> > Hi,
> >
> > the Split() function seems to have problems splitting against the ASCII NUL
> > (aka "\0") byte. In the attached project, there are four test cases from
> > whose results I assume that Split() stops working on the separator when it
> > encounters a NUL just if it was a C string. Look especially at the last
> > test.
> >
> > I currently work around this issue by using the "tr" program.
> >
> > Regards,
> > Tobi
> >
> >
> > ------------------------------------------------------------------------------
> > Get your SQL database under version control now!
> > Version control is standard for application code, but databases havent
> > caught up. So what steps can you take to put your SQL databases under
> > version control? Why should you start doing it? Read more to find out.
> > http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> >
> >
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> This will always occur in any language, as a string is terminated by the
> null character internally.
>
Bzzzt! Wrong. In Gambas a string is a structure containing a pointer and a
length so that the data can contain as much NUL as you want. Look at [0] and
especially at [1] were I was told the same thing.
Split() may be one of the functions mentioned there which by design (not by
bug) do not support "\0" but in my imagination - without knowing the code -
it should be as easy as using memmem() instead of strstr() to find a Gambas
string (Separator) in another Gambas string (Text) and to split accordingly.
Regards,
Tobi
[0] http://gambasdoc.org/help/lang/type/string?v3
[1] http://sourceforge.net/mailarchive/message.php?msg_id=29289747
More information about the User
mailing list