fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 231: Test if bytes are a valid UTF-8 string
Idiom # 231: Test if bytes are a valid UTF-8 string
See
programming-idioms.org
:
Code
Code input
b := String.from s .codepoints_and_errors ∀ (.ok)
What are effects?
Runnable Example
Code input
ex231 is bytes_ok := [u8 1; u8 2; u8 3; u8 4; u8 5] bytes_not_ok := [u8 200; u8 1; u8 201; u8 2; u8 203] s0 := bytes_ok b0 := String.from s0 .codepoints_and_errors ∀ (.ok) say "utf8? $s0: $b0" s1 := bytes_not_ok b1 := String.from s1 .codepoints_and_errors ∀ (.ok) say "utf8? $s1: $b1"
What are effects?
last changed: 2026-02-20
next: Idiom # 232: Read a command line boolean flag