date formatter create issues with string.Contains because of extra characters - by Dominique Lorre

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 779284 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/15/2013 3:20:09 AM
Access Restriction Public


string.Contains returns false when checking a formatted date because there are extra LRM (U+200E)characters inserted in the string:
Sign in to post a comment.
Posted by Tarek [MSFT] on 4/4/2013 at 12:08 PM

Thanks for your suggestion. String.Contain is a generic purpose method that should work with all strings. so ignoring the mark can break other scenarios (which expect to account for the marks).
Posted by Dominique Lorre on 2/20/2013 at 10:37 AM
Thanks for your input, the reason why I need to do this is that my Windows Store application displays a list with dates and I wanted to be able to search by dates when using the Search charm.

Thank you also for the suggestion, I have done this exactly as a workaround, but I wanted to signal this issue because I was unaware that it was done by design.

Maybe string.Contains() could ignore these marks?
Posted by Tarek [MSFT] on 2/20/2013 at 10:26 AM
DateTimeFormatter is designed to format dates to be consumed by the user. The RTL (0x200F) and LTR (0x200E) marks that are inserted are there to ensure that the date is formatted correctly. Without them the user will not always see the correct result. Parsing of these formatted dates is not a supported scenario. If you would like to provide more details as to why you are searching for the contents of a formatted date, we may be able to provide better guidance about how to accomplish your goal
Using a linguistic comparison would have succeeded (though I would bet that he is abusing this so wouldn't really want to suggest that)
The workaround can be stripping the LTM and RTM marks from the string before searching it.

Posted by Dominique Lorre on 2/18/2013 at 11:17 PM
Bug found while coding for Windows Store, not desktop.
Posted by Microsoft on 2/18/2013 at 10:51 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.