github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/readline/read.go (about)

     1  package readline
     2  
     3  func removeNonPrintableChars(s []byte) int {
     4  	var (
     5  		i    int
     6  		next int
     7  	)
     8  
     9  	for next = 0; next < len(s); next++ {
    10  		if s[next] < ' ' && s[next] != charEOF && s[next] != charEscape &&
    11  			s[next] != charTab && s[next] != charBackspace {
    12  
    13  			continue
    14  
    15  		} else {
    16  			s[i] = s[next]
    17  			i++
    18  		}
    19  	}
    20  
    21  	return i
    22  }