Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Length Field ignores TrimChars from FieldTrimAttribute #281

Open
kevinmbrooks opened this issue Feb 8, 2018 · 1 comment
Open

Comments

@kevinmbrooks
Copy link

Using the FieldTrimAttribute with the FieldFixedLengthAttribute trims whitespace correctly, but when you specify trim characters in the FieldTrimAttribute constructor, they are ignored and whitespace is still trimmed. A brief look at the code suggests to me that delimited fields are handling trim characters correctly, but fixed length fields are ignoring them.

I've only just started to look at the code, but it looks like FileBase.TrimString could be modified to care about TrimChars (or LineInfo.WhitespaceChars if TrimChars is null or empty).

@bcallaghan-et
Copy link

This is still an issue in 2023. When using a [FieldFixedLength] attribute in combination with a [FieldTrim(TrimMode.Right, '0')] (for example), the trailing zeros are not trimmed as expected. An examination of the source code shows that FieldBase.TrimChars is not used by the FieldBase.TrimString method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants