VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Valid & fast TrimNull

Vesa Piittinen  (20 Submissions)   String Manipulation   Advanced   Wed 3rd February 2021

While I think these TrimNull functions are a bit silly business, I guess they're mostly used due to lack of understanding of Windows API return values or of the file that is being processed, here you can find proper implementations of the LTrim & RTrim equivalents for NULL characters. Instead of InStr of any kind the string is processed as Integer array, without making a new copy of the string. This allows full control over the validation process and thus string is properly parsed from any NULLs at the end or beginning of a string.


A test program is included for comparison which shows the bugs in other implementations. Also a bit fuzzy logic RTrimZZ is included: it is fast, but it is mostly dedicated to cases where you expect a buffer full of NULL, except for the actual data at the beginning of the string.


The functions are long but fast.

Rate Valid & fast TrimNull (3(3 Vote))

Download Valid & fast TrimNull

Valid & fast TrimNull Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters