github.com/xyproto/orbiton/v2@v2.65.12-0.20240516144430-e10a419274ec/replacer.go (about) 1 package main 2 3 import ( 4 "strings" 5 ) 6 7 // opinionatedStringReplacer is a Replacer that can be used for fixing: 8 // nonbreaking spaces, annoying tildes, \r\n and \r 9 var opinionatedStringReplacer = strings.NewReplacer( 10 // Replace non-breaking space with regular space 11 string([]byte{0xc2, 0xa0}), string([]byte{0x20}), 12 // Fix annoying tilde 13 string([]byte{0xcc, 0x88}), string([]byte{'~'}), 14 // Fix greek question mark that looks like semicolon 15 string([]byte{0xcd, 0xbe}), string([]byte{';'}), 16 // Replace DOS line endings with UNIX line endings 17 string([]byte{'\r', '\n'}), string([]byte{'\n'}), 18 // Replace any remaining \r characters with \n 19 string([]byte{'\r'}), string([]byte{'\n'}), 20 )