Verificare se in una stringa vi sono caratteri non stampabili

Da Gambas-it.org - Wikipedia.

In Gambas attualmente non esiste una specifica funzione per sapere se un carattere è stampabile o meno.
Ricordiamo che un carattere stampabile non è un carattere di controllo, e pertanto è compreso fra il num. 32 ed il num. 126 del codice ASCII.

Potremo utilizzare, nel frattempo, la funzione IsPrint() del linguaggio C.


Mostriamo un possibile esempio:

' int isprint(int c)
' Check whether the passed character is printable.
Private Extern isprint(num As Integer) As Integer In "libc:6"


Public Sub Main()

 Dim s As String = "Testo\nqualsiasi"
 Dim bb As Byte[]
 Dim b As Byte

  bb = Byte[].FromString(s)
  
    For Each b In bb
      Print CBool(isprint(CInt(b)))
    Next
 
End