lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In a project I'm working on that interops Lua w/ PHP, .Net/COM, and
SQLite the 'string' types don't always work the best for data, since
the string may null-terminate in .Net... and SQLite needs to know if
data is a 'BLOB' or 'TEXT', especially for backup-restore.

My current method is to store known-binary strings in a table, tagged
with isByteArray as a value.  As a backup for unknown strings that go
into the database, I check for ASCII-safe bytes and tag it binary if
its not.

Another method I figured out is having a global isByteArray table w/
weak-refs to the strings as keys and true/nil testing.  This looks
best from the perspective of transparency... but the problem is that
ANY string with the same contents is automatically assumed binary...
which I'm not positive if I want that since a potential 'assumed
binary' value may in fact be a normal string.... This would cause a
simple 'string' in .Net to be managed as an array of bytes.

I'd love to be able to attach values to specific string instances...
but I doubt that's possible due to the fact that string values are
shared between all instances.

--
Thomas Harning Jr.