String Character Length: Difference between revisions

Content deleted Content added
mNo edit summary
revert vandalism
Line 59:
char *p = (char *) string;
while (*p ++ != '\0') length ++;
return 0;
Line 93:
}
 
==[[C plus plus|C ++]]==
[[Category:C plus plus|C ++]]
 
'''Standard:''' [[ISO C plus plus|ISO C ++]] (AKA [[C plus plus 98|C ++98]]):
 
'''Compiler:''' g ++ 4.0.2
 
#include <string> // note: '''not''' <string.h>
Line 124:
 
'''Platform:''' [[.NET]]
'''Language Version:''' 1.0 +
 
string s = "Hello, world!";
Line 195:
 
Since Java 1.5, the actual number of characters can be determined by calling the codePointCount method.
String str = "\uD834\uDD2A"; //U +1D12A
int length1 = str.length(); //2
int length2 = str.codePointCount(0, str.length()); //1
Line 208:
var len1 = str1.length; //13
var str2 = "\uD834\uDD2A"; //U +1D12A represented by a UTF-16 surrogate pair
var len2 = str2.length; //2