When an argument to String.Format has no formatter, its ToString method
is called. This change takes care that the FormatHelper can handle
arguments whose ToString() method returns null.
The MSDN documentation states "Because CompareOrdinal is a static method, strA and strB can be null. If both values are null, the method returns 0 (zero), which indicates that strA and strB are equal. If only one of the values is null, the method considers the non-null value to be greater." Previously, CompareOrdinal and CompareOrdinalCaseInsensitive would throw a NullReferenceException if strA or strB was null.
Keep the previously correct behaviour about returning new String[1]{Empty} if StringSplitOptions.RemoveEmptyEntries is not passed, and add a test for it (it wasn't being tested before).
* String.cs (LastIndexOf): All all overloads to
be compatible with MS with empty strings.
* String.cs (LastIndexOfAny): Ditto.
* StringTest.cs: Add tests for the above.
Fixes#605340
so that:
- it properly obeys the 'count' parameter; Fixes#601772.
- "...".Split(new[]{"."}, 2, StringSplitOptions.RemoveEmptyEntries).Length==0
- "A..".Split (new String[] { "." }, 2, StringSplitOptions.RemoveEmptyEntries) == new[]{"A"}
- Remove duplicative array handling code by using List<String>.
* Test/System/StringTest.cs: Add tests for #601772 (i.e. take
SplitStringChars(), change all the chars to Strings, and things
should work).
svn path=/trunk/mcs/; revision=158670
For bug: https://bugzilla.novell.com/show_bug.cgi?id=480152
* Normalization.cs: The correct "checkType" argument to
Decompose() is NKD or NKFD when normalizing to NKC resp. NKFC.
* StringTest.cs: More NFC test cases.
svn path=/trunk/mcs/; revision=155965
For bug: https://bugzilla.novell.com/show_bug.cgi?id=480152
* Normalization.cs: Implement algorithmic Hangul composition.
Calling Normalize(NormalizationForm.FormC) on Korean characters
now works properly (bnc#480152).
* StringTest.cs: Add test cases for Hangul composition.
svn path=/trunk/mcs/; revision=155964
For bug: https://bugzilla.novell.com/show_bug.cgi?id=480152
* Normalization.cs: Follow the spec when checking composition pairs.
Figure 7 in section 1.3 of http://unicode.org/reports/tr15/ shows
how when doing composition, one has to examine the successive
(starter, candidate) pairs, and combine if a matching canonical
decomposition exists.
The original algorithm was, instead, iterating on canonical
decompositions, and, for each one, trying to match a sequence
of (starter, non-starter, ...). This, however, does not produce
the same results as it is violating some implicit ordering
constraints in the Unicode tables.
E.g., when composing the following sequence of codepoints, the
original algorithm was picking:
03B7 0313 0300 0345
^^^^ ^^^^
1F74 0313 0345
^^^^ ^^^^
1FC2 0313
and would stop at 1FC2 0313 as there is no decomposition matching
it. The new algorithm, which follows the guidance of the pretty
figure 7, ends up doing:
03B7 0313 0300 0345
^^^^ ^^^^
1F20 0300 0345
^^^^ ^^^^
1F22 0345
^^^^ ^^^^
1F92
resulting in the correct 1F92.
svn path=/trunk/mcs/; revision=155963
For bug: https://bugzilla.novell.com/show_bug.cgi?id=480152
* Normalization.cs: Recursively apply the Unicode decomposition mapping.
According to http://www.unicode.org/reports/tr15/tr15-31.html,
section 1.3:
"To transform a Unicode string into a given Unicode Normalization
Form, the first step is to fully decompose the string. [...] Full
decomposition involves recursive application of the
Decomposition_Mapping values, because in some cases a complex
composite character may have a Decomposition_Mapping into a
sequence of characters, one of which may also have its own
non-trivial Decomposition_Mapping value."
svn path=/trunk/mcs/; revision=155962
2009-12-19 Zoltan Varga <[email protected]>
* String.cs: Fix the various IndexOf and LastIndexOf methods so they handle
"" and a non-zero startIndex correctly. Fixes#566106.
In Test/System:
2009-12-19 Zoltan Varga <[email protected]>
* StringTest.cs: Add tests for IndexOf ("", startIndex, count).
svn path=/trunk/mcs/; revision=148789
2009-10-27 Sebastien Pouliot <[email protected]>
* String.cs: Remove unused (and unneeded) internal call defs.
Reduce duplication (and fix test) for Concat (object,object).
Avoid allocating zero-length strings in the cases where the
FX does not do so.
In Test/System.Text:
2009-10-27 Sebastien Pouliot <[email protected]>
* UnicodeEncodingTest.cs: Add test cases with an odd number of
bytes being used in GetString (it does not crash but it does not
work like MS FX either).
In Test/System:
2009-10-27 Sebastien Pouliot <[email protected]>
* StringTest.cs: Add test case for methods that can return
empty strings.
In System.Globalization:
2009-10-27 Sebastien Pouliot <[email protected]>
* TextInfo.cs: Avoid allocating zero-length strings in ToLower
and ToUpper methods
svn path=/trunk/mcs/; revision=144921
* Normalization.cs : Handle blocked characters which are not
immediately next to the primary composite character. This fixes
some Arabic string sequence normalization.
* Makefile : fix test build.
* StringTest.cs : add more normalization tests.
svn path=/trunk/mcs/; revision=142249
* Normalization.cs :
- reverted the previous index calculation change. It was correctly
implemented and I rather broke it.
- fix index calculation on combining.
- NFKD was incorrectly directed to combining path. It should not.
- Simplify quick check.
* StringTest.cs : Fix the previous test. It was expecting wrong
results. Added another NFC composition test.
svn path=/trunk/mcs/; revision=136474
* Environment.cs : bump corlib version.
* Normalization.cs : For NFC and NFKC, IsNormalized() was not working
enough to check composed characters. It's not possible without
the actual composition, so just call Normalize() and compare them.
In Normalize() mapping helper didn't pick correct map index since
the table for index stores index for "uncompressed" numbers.
* NormalizationTableUtil.cs : updated to the latest UCD.
* Makefile : to build test, source file must be downloaded too.
* StringTest.cs : added string normalization test.
svn path=/trunk/mcs/; revision=136100
* StringBuilder.cs (ToString): Use String.SubstringUnchecked instead
of String.Substring, as the former is guaranteed to create a new
string object. Fixes bug #395904.
* String.cs (Substring): Blocking bug #395904 has been fixed,
re-enable optimization.
* StringTest.cs (Substring2): Blocking bug #395904 has been fixed,
re-enable test.
svn path=/trunk/mcs/; revision=104629
* StringTest.cs: Comment out a test that currently fails by checking for
an obsolete parameter name in an exception (that doesn't even match the existing one)
svn path=/trunk/mcs/; revision=104621
causes regressions in System.Xml.
* StringTest.cs: Comment out assert in SubString2 as corresponding
fix was reverted.
svn path=/trunk/mcs/; revision=103994