u/FloatingVectors

▲ 1 r/golang

golang strings.Trim(...) - for semicolons?

I'm new to go, and I'm trying to parse some file. Go has this convenient strings.Trim() function:

https://pkg.go.dev/strings#Trim

I seem to have an issue, when I try to strip semicolons (;):

On the site linked above, I changed the example code from:

fmt.Print(strings.Trim("¡¡¡Hello, Gophers!!!", "!¡"))

to:

fmt.Print(strings.Trim("¡¡¡Hello, Gophers;!!!;", ";"))

I'd expect it to remove all semicolons, yet it only removes the last one.

I also noted that the following string / cutset combination only removes the trailing exclamation mark:

fmt.Print(strings.Trim("¡¡¡Hello, Gophers;!;!!", "!"))

How should I use the Trim function, so I get rid of all semicolons?

Do I need to sanitize the input string?

reddit.com
u/FloatingVectors — 8 days ago

Hello,

I just picked up a HP 7585B pen plotter, it has a HPIB and a serial port. There is a service manual online on bitsavers, but no online users guide. I can send a few commands if I short RTS/CTS, so it does work and uses hardware handshake. If I send a file, the "ERROR" led lights up and the plotter stops. Probably because the internal buffer is full.

The HP 7470A Graphics Plotter: Interfacing and Programming Manual lists four methods of handshaking: hardwire handshake, Xon-Xoff handshake, enquire/acknowledge handshake, and software checking handshake.

Does anyone know which handshake methods the HP 7585B supports?

Most USB-serial converters don't support RTS/CTS (I checked three different ones, no luck) so I'd prefer to use some software handshake. Xon/Xoff did not seem to work out of the box, not sure if it needs command to be sent first ("PLOTTER ON"?).

If someone happens to have the users guide or programming manual, a quick look up would be very helpful!

reddit.com
u/FloatingVectors — 19 days ago