utf8.single-byte-char

pattern

Library: UTF-8 (OMUTF8)
Import : omutf8.xmd

Declaration
export switch function 
   single-byte-char


Purpose

The function utf8.single-byte-char matches only ASCII UTF-8 encoded characters (those with numeric values 0 to 127).

Example

The following program uses utf8.single-byte-char to match single-byte UTF-8 characters and re-emit them as-is:

  import "omutf8.xmd" prefixed by utf8.
  
  process
     repeat scan "flamb%195#%169#"
     match utf8.single-byte-char+ => c
        output c
  
     match utf8.multi-byte-char => c
        local integer n initial { utf8.code-point of c }
  
        do when n > 255
           output "&#x" || "16rud" % n || ";"
  
        else
           output "b" % n
        done
    again

Usage Note

To use utf8.single-byte-char, you must import OMUTF8 into your program using an import declaration such as:

  import "omutf8.xmd" prefixed by utf8.