LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy/pasting from Word appends a null (/00) character?


@billko wrote:

@Kyle97330 wrote:

I've had so many problems with text inputs from users being weird that I run pretty much every text field input through a sanitizer.  The standard one I use trims whitespace from both ends, removes any non-printable characters, and if there's ever two or more spaces in a row in the middle it trims them down to just one space.

 

Add in a case-insensitive equals check and the whole thing makes all string operations a lot smoother when they have to deal with strings from any sort of external input.

 

There can be exceptions, like places where monospaced fonts are used and exact space counts actually are useful, but those are the exception rather than the general rule.


I don't think a null counts as "whitespace".


Oh wow.... your right!

Frozen_0-1743436049476.png

 

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Message 11 of 12
(54 Views)

It doesn't, though if you're looking at what I wrote please note that I also mentioned removing all non-printable characters as a standard.  A null does not pass that check.

 

The "printable" check actually also removes tabs, newlines, and carriage returns.  In nearly all cases I don't expect or want those in the strings I get as inputs, since mostly what I get as inputs are things like serial numbers or product numbers, which might have letters or punctuation but never a tab.

Message 12 of 12
(49 Views)