PC Review


Reply
Thread Tools Rate Thread

CHR(0) - breaking change in CF 3.5?

 
 
Benjamin Lukner
Guest
Posts: n/a
 
      5th May 2009
Hi!

Dim NULL1 As Char = Chr(0)

I use a phrase like this ever since to generate a char that contains
ASCII character 0x00.

When running with CF 3.5, the variable is set to Nothing instead!

Can anybody confirm this behaviour? Bug or feature?

Regards,

Benjamin Lukner
 
Reply With Quote
 
 
 
 
Sid
Guest
Posts: n/a
 
      5th May 2009
On May 5, 5:41*pm, Benjamin Lukner <b.luk...@zetes-ind.com> wrote:
> Hi!
>
> Dim NULL1 As Char = Chr(0)
>
> I use a phrase like this ever since to generate a char that contains
> ASCII character 0x00.
>
> When running with CF 3.5, the variable is set to Nothing instead!
>
> Can anybody confirm this behaviour? Bug or feature?


Hi there! Does not seem to be a "feature"... how can it be? A
character is a character, not Nothing...
In fact creating a Char with Chr(0) does set it to Nothing. And
Msgboxing Nothing gives an empty dialog.

Also watching the variable show it to be Nothing.

So I confirm the behavior, but don't know why this happen... Let us
informed!
 
Reply With Quote
 
Benjamin Lukner
Guest
Posts: n/a
 
      6th May 2009
Hi!

It's not about the CHR(0) itself. This is regular behaviour.
A message box always stops displaying at the first 0 character because
this indicates the end of the string.

That the DevEnv displays "Nothing" may be a feature or simply a bug.
Nevertheless it still is character 0.

The problem I experience is about the String.Replace() method.
I'll post another topic for this.

Kind regards,

Benjamin Lukner
 
Reply With Quote
 
Christopher Fairbairn [MVP]
Guest
Posts: n/a
 
      7th May 2009
Hi,

"Benjamin Lukner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The problem I experience is about the String.Replace() method.
> I'll post another topic for this.


If your string contains an embedded NULL character (which according to the
System.String documentation is a completely valid situation) .NET CF 3.5 may
not behave in the same way as previous releases.

Take a look at the following forum thread for example ".NET CF 3.5 Bug -
StringBuilder.Replace truncates result if data contains null character" -
available at
http://social.msdn.microsoft.com/For...b-9423411800b8

Is this the situation you are finding yourself in? It would help if you
could share a small code snippet demonstrating the issue you are finding.

Hope this helps,
Christopher Fairbairn


 
Reply With Quote
 
Benjamin Lukner
Guest
Posts: n/a
 
      7th May 2009
> Is this the situation you are finding yourself in? It would help if you
> could share a small code snippet demonstrating the issue you are finding.



Hi,

yes, that's the situation I experience.
I posted two messages but the second message (new topic) did not appear
here, though it's in my sent items folder. Here is a copy of that message:

Hi!

I experience a problem regarding the String.Replace() method when
running a .Net CF application with CF3.5:

When the second parameter is a string of CHR(0) the output string will
be truncated. This only occurs with CF3.5!

Running CF1.0 program with CF1.0 runtime: OK
Running CF1.0 program with CF2.0 runtime: OK
Running CF1.0 program with CF3.5 runtime: FAIL

Running CF2.0 program with CF2.0 runtime: OK
Running CF2.0 program with CF3.5 runtime: FAIL

Running CF3.5 program with CF3.5 runtime: FAIL


SAMPLE CODE:

Dim c0 As Char = Chr(0)
Dim s0 As String = New String(Chr(0), 1)

Dim s As String = "123X" + Chr(0) + "456"

' Expected: "123XX456"
MsgBox(s.Replace("X"c, c0).Replace(c0, "X"c)) '1A
MsgBox(s.Replace("X", c0).Replace(c0, "X")) '1B
MsgBox(s.Replace("X", s0).Replace(s0, "X")) '1C

' Expected: 8
MsgBox(s.Replace("X"c, c0).Length.ToString) '2A
MsgBox(s.Replace("X", c0).Length.ToString) '2B
MsgBox(s.Replace("X", s0).Length.ToString) '2C

' Expected: "X"
MsgBox(s0.Replace(c0, "X"c)) '3A
MsgBox(s0.Replace(c0, "X")) '3B
MsgBox(s0.Replace(s0, "X")) '3C


CONCLUSION:

When replacing any char with char 0 there's no problem at all.
But when replacing with a String of char 0 the output string will be
truncated: 1B, 1C, 2B, 2C will fail with CF3.5 but work with all other
runtime versions.

Kind regards,

Benjamin Lukner
 
Reply With Quote
 
Christopher Fairbairn [MVP]
Guest
Posts: n/a
 
      7th May 2009
Hi Benjamin,

"Benjamin Lukner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I experience a problem regarding the String.Replace() method when running
> a .Net CF application with CF3.5:
>
> When the second parameter is a string of CHR(0) the output string will be
> truncated. This only occurs with CF3.5!


This has been identified as a bug in the .NET CF 3.5 runtime.

As the Microsoft developers in the MSDN forum thread I referenced suggested
you may like to take a look at Microsoft's bug tracking system
(http://connect.microsoft.com/) and check if it has already been posted
there. If it has then you could post a validation saying the issue is
affecting you, alternatively if it hasn't you could create a new case.

If you have a copy of Visual Studio with MSDN you may also be able to use a
Service Request with Microsoft Technical Support to get feedback directly
from Microsoft (see details on how this option works at
http://blogs.msdn.com/raffael/archiv...-paid-for.aspx)

Hope this helps,
Christopher Fairbairn


 
Reply With Quote
 
Benjamin Lukner
Guest
Posts: n/a
 
      29th May 2009
Christopher Fairbairn [MVP] wrote:
[...]
> As the Microsoft developers in the MSDN forum thread I referenced suggested
> you may like to take a look at Microsoft's bug tracking system
> (http://connect.microsoft.com/) and check if it has already been posted
> there. If it has then you could post a validation saying the issue is
> affecting you, alternatively if it hasn't you could create a new case.


Thanks for the information, I just posted the issue. But the sign up
procedure is rather complicated I think and takes much effort. There are
only a few steps but several confirmation mails and typing codes et
cetera. In fact it seems like Microsoft tries to keep away users from
the service...

Kind regards

BL
 
Reply With Quote
 
Benjamin Lukner
Guest
Posts: n/a
 
      29th May 2009
Christopher Fairbairn [MVP] wrote:
[...]
> As the Microsoft developers in the MSDN forum thread I referenced suggested
> you may like to take a look at Microsoft's bug tracking system
> (http://connect.microsoft.com/) and check if it has already been posted
> there. If it has then you could post a validation saying the issue is
> affecting you, alternatively if it hasn't you could create a new case.


Thanks for the information, I just posted the issue. But the sign up
procedure is rather complicated I think and takes much effort. There are
only a few steps but several confirmation mails and typing codes et
cetera. In fact it seems like Microsoft tries to keep away users from
the service...

Kind regards

BL
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Breaking change in MS DLL's ? Rob Microsoft VC .NET 11 4th Nov 2009 01:58 AM
non-breaking space: change in Outloook 2007; why? Peter J. Veger Microsoft Outlook VBA Programming 0 17th Aug 2008 12:18 PM
RadioButtonList .NET 2.0 Breaking Change aamillsbit@gmail.com Microsoft Dot NET Framework 0 9th May 2006 06:33 AM
2.0 breaking change. Can't figure it out. William Stacey [MVP] Microsoft C# .NET 0 7th Jun 2005 03:28 AM
Re: Breaking Change in SP1/SP2 Chris J.T. Auld [MVP] Microsoft Dot NET Compact Framework 1 9th Feb 2004 07:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:50 PM.