Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET (409 Views)
Reply
Regular Advisor
Ralf_Wegener
Posts: 131
Registered: ‎08-21-2010
Message 1 of 7 (409 Views)
Accepted Solution

Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

[ Edited ]

Haven't tested with other versions - Extracting data from an external datasource converted to string and appending to a notes field or a UDF with text data type. I've noticed that I'm missing data where the character set / byte is  zero or null (or byte = 0 or null) in a given string...So if I have over 200 characters in a a string and I set record.notes or or record.setuserfield(udf,stringvalue); the result in TRIM only contains values prior to byte value of 0.

 

Below is my workaround to resolve in 7.34...could be incorrect coding on my part. Below is my workaround. Has anyone experienced similar issues.

 

public override string ToString()
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < data.Length; i++)
                {

                    char c = data[i];
                    byte b = (byte)c;

                    if (b == 0)
                    {
                        _Log.Debug("Char " + c + " Byte " + b);                    
                    }
                    else sb.Append(c);
                }

                _trimrecord.Notes = sb.ToString();
                return sb.ToString();
                return data;
            }

Regular Advisor
Ralf_Wegener
Posts: 131
Registered: ‎08-21-2010
Message 2 of 7 (384 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

Emphasis on custom TRIM SDK. standard copy and paste TRIM functionality is not an issue at all...and or using off the shelf TRIM modules/functions.
Honored Contributor
EWillsey
Posts: 1,877
Registered: ‎04-20-2010
Message 3 of 7 (376 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

It could be because it's a Monday morning here, but I'm not sure I follow.  Are you asking why the notes are blanked out when you save a 0 byte / null string to the notes field?  If you're an admin and can overwrite notes, that would be the appropriate method.  Otherwise use the "AppendNotes" method to ensure you're always adding to notes (instead of possible overwriting).

Regular Advisor
Ralf_Wegener
Posts: 131
Registered: ‎08-21-2010
Message 4 of 7 (365 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

TRIM permissions are correct. if i try appending or overwriting the notes field or a user defined field where the data type is Text and a zero byte value exists somewhere in the string value; when I save - TRIM only saves the characters in the string value before the occurrance of the zero btye character. 

Esteemed Contributor
Richard Kelly_7
Posts: 205
Registered: ‎02-15-2007
Message 5 of 7 (353 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

[ Edited ]

A \0 (null character) always used to be a string terminator when I was coding C in ASCII.  These days it's all C# and Unicode so don't see it much any more.  I think it is not unreasonable to go through your input and replace any null with (for example) a space before passing it - as far as I can see you will have to do this as an array rather than using string manipulation (as you are doing) otherwise it will also fail.    I am guessing your Dataset is not running in Unicode either - but your problem is before you even look at that......

Note: Any posts I make on this forum are my own personal opinion and do not constitute a formal commitment on behalf of HP.
Regular Advisor
Ralf_Wegener
Posts: 131
Registered: ‎08-21-2010
Message 6 of 7 (338 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

[ Edited ]

Thanks Mate. Did not think about splitting string to an array using /0 as a delimiter - rather then looping through each character in the string. But I still  think there is an anomaly with trim stripping out data post /0 character. An error should be raised at the very least on verify?.

 

Cheers

Esteemed Contributor
Richard Kelly_7
Posts: 205
Registered: ‎02-15-2007
Message 7 of 7 (320 Views)

Re: Zero Byte Character - Set Notes Field or User Defined Field - Missing Values - TRIM SDK.NET

Don't think you can validate and check it is missing - try using string functionality in your programming language and almost certainly you will find that is what is stripping out the post-null part of the string - it's not TRIM/RM that is doing it.

Note: Any posts I make on this forum are my own personal opinion and do not constitute a formal commitment on behalf of HP.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.