View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0000798||LDMud 3.5||Efuns||public||2011-12-09 17:56||2018-01-30 04:59|
|Target Version||3.5.0||Fixed in Version||3.5.0|
|Summary||0000798: deprecate/remove strlen()|
|Description||As far as I can tell, strlen() does exactly the same as sizeof() with the one exception that it only accepts strings as argument. But exactly in this there is an inconsistency: usually, efuns that expect strings as argument throw an error upon passing 0. strlen accepts 0.|
So, if there are no internal differences between strlen() and sizeof() that favor strlen() I suggest to deprecate it and in some future after 3.5 remove it. If someone really needs it at that point for compatibility, a sefun returning sizeof() does the trick.
|Tags||No tags attached.|
These two efuns currently have the same result, but not really the same meaning.
We discussed that 2-3 years ago in some issue about wide char strings.
As soon as we will introduce wide char strings (e.g. UTF16), sizeof() and strlen() will start to differ (sizeof(): no of bytes, strlen(): no of characters).
Therefore I always recommend to use strlen() if a wizard wants to know the no of characters.
So I don't think we should deprecate strlen().
||I disagree. Even with unicode support sizeof() should return the number of characters, not bytes. Sizeof() never returns the number of bytes, it returns the number of elements in arrays, mappings or strings. And it does so because the number of bytes are not relevant to the wizard in any way. Also for wide strings all string indexing functions would work on a character basis, so the byte count is never needed.|
||So I'm in favor of deprecating strlen().|
I was sure, the discussion a few years ago was in the other direction. ;-) But maybe it was not you, but someone else. I agree, that the indexing operator for strings should work on the basis of characters.
One problem is, that for some applications you have to know to length of a string in bytes (e.g. you want to send over the network and no \0 termination). They might be rarely used in MUDs, but I would take them into account.
||When sending a unicode string you first have to convert it into a specific encoding, yielding a kind of array of bytes. This byte array is no more a unicode string, but would be treated like a ASCII string (the kind we have now), where strlen() and sizeof() would return the number of bytes (as it is now).|
I will add a comment to the manpage of strlen(). But we will wait a bit for deprecating strlen() in the code so that our users can first work on a plethora of new type errors in their mudlibs. ;-)
We will also remove this one in 3.5.0 since it is a simple replacement by script or sefun.
||Fix committed in revision 41a17400ede247f0ef6b894d204f66baddbc41ab to master branch (see changeset 1044 for details). Thank you for reporting!|
||Fix committed in revision 41a17400ede247f0ef6b894d204f66baddbc41ab to master branch (see changeset 1350 for details). Thank you for reporting!|
||Fix committed in revision 41a17400ede247f0ef6b894d204f66baddbc41ab to master branch (see changeset 2676 for details). Thank you for reporting!|
||Fix committed in revision 41a17400ede247f0ef6b894d204f66baddbc41ab to master branch (see changeset 3763 for details). Thank you for reporting!|
|2011-12-09 17:56||Sorcerer||New Issue|
|2011-12-10 00:47||zesstra||Note Added: 0002088|
|2011-12-10 00:54||Gnomi||Note Added: 0002089|
|2011-12-10 01:00||Gnomi||Note Added: 0002090|
|2011-12-10 01:02||zesstra||Note Added: 0002091|
|2011-12-10 01:08||Gnomi||Note Added: 0002092|
|2014-02-23 23:41||zesstra||Note Added: 0002233|
|2014-02-23 23:41||zesstra||Status||new => confirmed|
|2014-02-23 23:46||zesstra||Source_changeset_attached||=> ldmud.git master a9de3f24|
|2014-02-23 23:49||zesstra||Target Version||=> 3.5.0|
|2015-05-10 22:29||zesstra||Note Added: 0002255|
|2015-05-10 22:29||zesstra||Assigned To||=> zesstra|
|2015-05-10 22:29||zesstra||Status||confirmed => assigned|
|2016-01-20 17:17||zesstra||Source_changeset_attached||=> ldmud.git master 41a17400|
|2016-01-20 17:17||zesstra||Note Added: 0002273|
|2016-01-20 17:17||zesstra||Status||assigned => resolved|
|2016-01-20 17:17||zesstra||Resolution||open => fixed|
|2016-01-20 17:17||zesstra||Fixed in Version||=> 3.5.0|
|2018-01-29 19:59||zesstra||Source_changeset_attached||=> ldmud.git master 41a17400|
|2018-01-29 19:59||zesstra||Source_changeset_attached||=> ldmud.git master a9de3f24|
|2018-01-29 19:59||zesstra||Note Added: 0002305|
|2018-01-29 22:57||zesstra||Source_changeset_attached||=> ldmud.git master 41a17400|
|2018-01-29 22:57||zesstra||Source_changeset_attached||=> ldmud.git master a9de3f24|
|2018-01-29 22:57||zesstra||Note Added: 0002356|
|2018-01-30 04:59||zesstra||Source_changeset_attached||=> ldmud.git master 41a17400|
|2018-01-30 04:59||zesstra||Source_changeset_attached||=> ldmud.git master a9de3f24|
|2018-01-30 04:59||zesstra||Note Added: 0002407|