String Character Length: Difference between revisions
Content deleted Content added
m →[[Java]]: Use Java header instead |
m Switch to header template |
||
Line 5:
For byte length, see [[String Byte Length]].
==
myStrVar.length()
==
'''Compiler:''' GCC 4.1.2
Line 17 ⟶ 14:
Length : constant Natural := Str'Length;
==
count of "Hello World"
Line 24 ⟶ 20:
count "Hello World"
==
From within any code block:
w=length("Hello, world!") # static string example
Line 37 ⟶ 32:
{print"The length of this line is "length($0)}
==
'''Standard:''' [[ANSI C]] (AKA [[C89]]):
Line 96 ⟶ 89:
}
==
// Return the length in unicode characters
unsigned length = [@"Hello Word!" length];
Line 128 ⟶ 119:
}
==
'''Platform:''' [[.NET]]
'''Language Version:''' 1.0+
Line 150 ⟶ 139:
Start = strlen "Hello, world!"
==
#len("Hello World")#
==
(length "Hello World")
==
LEN("Hello, World!")
==
"Hello World".size()
==
The 1994 ANS standard does not have any notion of a particular character encoding, although it distinguishes between character and machine-word addresses. (There is some ongoing work on standardizing an "XCHAR" wordset for dealing with strings in particular encodings such as UTF-8.)
Line 198 ⟶ 177:
repeat drop ;
==
'''Interpreter:''' [[GHC | GHCi]] 6.6, [[Hugs]]
Line 207 ⟶ 184:
strlen = length "Hello, world!"
==
'''Compiler:''' any IDL compiler should do
Line 227 ⟶ 202:
int length2 = str.codePointCount(0, str.length()); //1
==
JavaScript encodes strings in UTF-16, which represents each character with one or two 16-bit values. The most commonly used characters are represented by one 16-bit value, while rarer ones like some mathematical symbols are represented by two.
Line 239 ⟶ 212:
var len2 = str2.length; //2
==
//Store length of hello world in length and print it
. length = "Hello World".length();
Line 249 ⟶ 220:
" Hello world" @ , # 11
==
'''Interpreter:''' [[Lua]] 5.0 or later.
Line 257 ⟶ 227:
length=#string
==
"Hello world".count
==
'''Interpreter:''' [[mIRC]]
alias stringlength { echo -a Your Name is: $len($$?="Whats your name") letters long! }
==
'''Interpreter'''/'''Compiler:''' [[Ocaml]] 3.09
Line 275 ⟶ 241:
==
'''Interpreter:''' [[Perl]] any 5.X
my $length = length "Hello, world!";
==
$length = strlen('Hello, world!');
==
DECLARE
string VARCHAR2( 50 ) := 'Hello, world!';
Line 296 ⟶ 257:
END;
==
'''Interpreter:''' [[Python]] 2.4
Line 311 ⟶ 270:
</pre>
==
'''Library:''' [[active_support]]
Line 318 ⟶ 276:
puts "Hello World".chars.length
==
(string-length "Hello world")
==
length("Hello, world!")
==
string := 'Hello, world!".
string size.
==
'''Interpreter:''' [[Standard ML of New Jersey | SML/NJ]] 110.60, [[Moscow ML]] 2.01 (January 2004)
Line 343 ⟶ 293:
val strlen = size "Hello, world!";
==
Basic version:
Line 358 ⟶ 306:
puts [format "length of \"%s\" in characters is %d" $s2 [string length $s2]]
==
With external utilities:
'''Interpreter:''' any
string='Hello, world!'
Line 378 ⟶ 324:
==
Len(string|varname)
Line 385 ⟶ 330:
Returns null if string|varname is null
==
'''Interpreter:''' HyperCard
|