String length: Difference between revisions

Content added Content deleted
(add Zig example)
No edit summary
Line 680: Line 680:
Length in bytes (UTF-16 encoding) = 10
Length in bytes (UTF-16 encoding) = 10
Length in bytes (UTF-8 encoding) = 7</pre>
Length in bytes (UTF-8 encoding) = 7</pre>

=={{header|BQN}}==
Strings are arrays of characters in BQN.
===Byte Length===
Each character is converted to its codepoint, and compared with the respective UTF boundary.
<lang bqn>BLen ← {(≠𝕩)+´⥊𝕩≥⌜@+128‿2048‿65536}</lang>

===Character Length===
Character length is just array length.
<lang bqn>Len ← ≠</lang>

'''Output'''
<lang bqn>•Show >(⊢⋈⊸∾Len⋈BLen)¨⟨
"møøse"
"𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
"J̲o̲s̲é̲"
⟩</lang>
<lang>┌─
╵ "møøse" 5 7
"𝔘𝔫𝔦𝔠𝔬𝔡𝔢" 7 28
"J̲o̲s̲é̲" 8 13
┘</lang>


=={{header|Bracmat}}==
=={{header|Bracmat}}==