Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
fork
What I like about
ctype
functions acceptingint
is that it's not possible to make them accept Unicode code points without breaking compliance because despite of acceptingint
, the value still has to be representable with 8 bits.Hobovsky is right; the Linux manpage for
ctype.h
functions gives more details:I think the reason behind this might be purely historical: these functions were implemented as O(1) lookup tables indexed by the value of
c
. This worked well for 7-bit ASCII, but if a negative value is passed this would access the lookup table out-of-bounds.The negative
char
s are not a remote possibility either: this will happen if you use modern UTF-8 encoded strings on a platform wherechar
is signed (which is pretty much all of them by default).The
<ctype.h>
functions are problematic for several reasons: they depend on the locale, they are inadapted to modern Unicode where "characters" span more than one byte, theis___()
predicates do not return abool
, the cast to(unsigned char)
is necessary if one wants to write clean code. But I use them on Codewars because I like to use builtins and I know that on Codewars they will always work the way I expect them to.That's because
cctype
functions do not work well with characters represented with negative values.cctype
functions acceptint
equivalent of one character as parameter, and if on a given platformchar
is signed, then characters above0x7F
end up being passed as a negativeint
, which might be not what such function expects.It makes sense, because
\
is misleading when presented in assertion messages.hey, thanks for the review :)
there was a bug in the
if ()
:len_act != len_in
-->len_act != len_exp
. fixed.fixed
Rejecting as issue has already been resolved
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
it's hard to remember all the symbols that are in the global namespace when you name things. in this particular case, not only it does not affect the user's code, but
input()
would never be used on Codewars anyways. But fine, renamed toinpt
done here
Not in this kata.
Fixed by fork above
Superceded by latest fork :(
Loading more items...