Differenze tra le versioni di "Verificare se in una stringa vi sono caratteri non stampabili"

Da Gambas-it.org - Wikipedia.
(Creata pagina con 'In Gambas attualmente non esiste una spoecifica funzione per sapere se un carattere è stampabile o meno. <BR>Ricordiamo che un carattere stampabile e quello che non è un ''c...')
 
Riga 15: Riga 15:
 
   Dim s As String = "Testo\nqualsiasi"
 
   Dim s As String = "Testo\nqualsiasi"
 
   Dim bb As Byte[]
 
   Dim bb As Byte[]
 +
  Dim b As Byte
 
   
 
   
 
   bb = Byte[].FromString(s)
 
   bb = Byte[].FromString(s)
 
    
 
    
     For Each s In bb
+
     For Each b In bb
       Print CBool(isprint(s))
+
       Print CBool(isprint(b))
 
     Next
 
     Next
 
    
 
    
 
  '''End'''
 
  '''End'''

Versione delle 08:56, 1 feb 2015

In Gambas attualmente non esiste una spoecifica funzione per sapere se un carattere è stampabile o meno.
Ricordiamo che un carattere stampabile e quello che non è un carattere di controllo.

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(b))
    Next
 
End