String length: Difference between revisions

added PowerShell
(completed character length and empasized that in lua a character is always one byte.)
(added PowerShell)
Line 727:
<lang pop11>lvars str = 'Hello, world!';
lvars len = length(str);</lang>
 
=={{header|PowerShell}}==
===Character Length===
<lang powershell>$s = "Hëlló Wørłð"
$s.Length</lang>
===Byte Length===
{{trans|C#}}
 
For UTF-16, which is the default in .NET and therefore PowerShell:
<lang powershell>$s = "Hëlló Wørłð"
[System.Text.Encoding]::Unicode.GetByteCount($s)</lang>
For UTF-8:
<lang powershell>[System.Text.Encoding]::UTF8.GetByteCount($s)</lang>
 
=={{header|Python}}==
Anonymous user