Strings are a fundamental component of Mathematica, as are the functions StringLength and SyntaxLength. Define the function
In[]:=
sanitycheck@arg_String:=(SyntaxLength@arg)<=(StringLength@arg)
It is obvious that sanitycheck must yield True for every valid string that can be constructed within Mathematica.
Now consider the very small subset of all possible single-character strings:
In[]:=
:=FromCharacterCode/@Range@200
We obtain
In[]:=
Out[]=
,,,,,,,\b, ,,,,,,,,,,,,,,,,,,,,,,, ,!,",#,$,%,&,',(,),*,+,,,-,.,/,0,1,2,3,4,5,6,7,8,9,:,;,<,=,>,?,@,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,[,\,],^,_,`,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,{,|,},~,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,, ,¡,¢,£,¤,¥,¦,§,¨,©,ª,«,¬,,®,¯,°,±,²,³,´,µ,¶,·,¸,¹,º,»,¼,½,¾,¿,À,Á,Â,Ã,Ä,Å,Æ,Ç,È
This is clearly a set of single - character strings:
In[]:=
Length@Union@
Out[]=
200
In[]:=
Head/@//Tally
Out[]=
{{String,200}}
In[]:=
StringLength/@//Tally
Out[]=
{{1,200}}
So here is the shocking result :
In[]:=
sanitycheck/@//Tally
Out[]=
{{True,193},{False,7}}
Why does such a basic function yield such obviously wrong results ? All the Mathematica functions shown here have been around for the last 32 years. It seems to me that the correction of basic flaws should be at least as important as ever-increasing elaborations.