Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
164bb0a
Implemented IndexOf and LastIndexOf functions
mkhamoyan May 30, 2023
1e4e9a5
Updated test cases
mkhamoyan May 31, 2023
292b915
Remove not needed parts
mkhamoyan May 31, 2023
9d23f7b
Implemented IsPrefix, IsSuffix functions
mkhamoyan Jun 1, 2023
1f8b5d5
Remove logs
mkhamoyan Jun 1, 2023
7b91b6c
Fix CI build failures
mkhamoyan Jun 2, 2023
c4a2d3c
Refactored
mkhamoyan Jun 2, 2023
001c366
Fixed some test cases for OSX
mkhamoyan Jun 6, 2023
0ec8d79
Minor changes in test cases
mkhamoyan Jun 6, 2023
fa7322c
test case minor refactoring
mkhamoyan Jun 6, 2023
fc2837b
Merge branch 'main' into hybrid_collation_functions
mkhamoyan Jun 6, 2023
a7ab572
Merge branch 'main' into hybrid_collation_functions
mkhamoyan Jun 7, 2023
36de1a9
Merge branch 'main' into hybrid_collation_functions
mkhamoyan Jun 14, 2023
139a6ba
Changed IndexOf functions implementation
mkhamoyan Jun 15, 2023
f3da1e5
Fix build failue
mkhamoyan Jun 15, 2023
5c3f172
Minor fixes
mkhamoyan Jun 15, 2023
ab317f7
Minor fix
mkhamoyan Jun 15, 2023
24094fe
Refactor as per review comments
mkhamoyan Jun 16, 2023
c425d38
Refactored Indexing functions calls
mkhamoyan Jun 16, 2023
a3f44b4
Updated doc and added comments
mkhamoyan Jun 16, 2023
cbaaf80
Applied changes suggested by @jkotas
mkhamoyan Jun 16, 2023
caebcbe
Refactored some files
mkhamoyan Jun 19, 2023
71b026e
Make the doc more readable
mkhamoyan Jun 19, 2023
9dda83a
Refactored IndexOf function
mkhamoyan Jun 19, 2023
88c6861
Add more comments in IndexOF function
mkhamoyan Jun 19, 2023
460aba0
remove localizedStandardRangeOfString
mkhamoyan Jun 20, 2023
db0a8f8
Initial changes for casing functions
mkhamoyan Jun 20, 2023
3d5a195
Added exception in case mixed compositions
mkhamoyan Jun 21, 2023
006bdb7
Merge branch 'hybrid_collation_functions' into hybrid_casing_functions
mkhamoyan Jun 21, 2023
24136fc
Merge branch 'main' into hybrid_casing_functions
mkhamoyan Jun 21, 2023
d9fa03b
Update test cases
mkhamoyan Jun 21, 2023
356b250
Refactor casing functions
mkhamoyan Jun 22, 2023
040f214
Updated doc and did refactoing
mkhamoyan Jun 22, 2023
583f7bb
align code lines
mkhamoyan Jun 22, 2023
a244198
Update test comment
mkhamoyan Jun 22, 2023
f7823a3
Merge branch 'main' into hybrid_casing_functions
mkhamoyan Jun 23, 2023
8c2efb4
Order alphabetically function declarations
mkhamoyan Jun 23, 2023
ba2f1b3
Done minor refactoring
mkhamoyan Jun 23, 2023
ddd17c4
Refactor as requested by review
mkhamoyan Jun 26, 2023
f39dd83
Minor refactoring
mkhamoyan Jun 26, 2023
f46a9ba
Fix casing function implementation
mkhamoyan Jun 27, 2023
6661e4f
Update doc and test cases
mkhamoyan Jun 27, 2023
60a945a
Fix index in Append function
mkhamoyan Jun 27, 2023
2257cbe
minor refactoring
mkhamoyan Jun 27, 2023
3ff5de7
Update method comment and remove GetCurrentLocale
mkhamoyan Jun 27, 2023
bb6fbf5
Use Interop.GlobalizationInterop.ResultCode
mkhamoyan Jun 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated doc and did refactoing
  • Loading branch information
mkhamoyan committed Jun 22, 2023
commit 040f214c911e9f09690c86add8f17c005e3d5f6c
25 changes: 24 additions & 1 deletion docs/design/features/globalization-hybrid-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,4 +408,27 @@ Affected public APIs:
- CompareInfo.GetSortKeyLength
- CompareInfo.GetHashCode

Apple Native API does not have an equivalent, so they throw `PlatformNotSupportedException`.
Apple Native API does not have an equivalent, so they throw `PlatformNotSupportedException`.


## Case change

Affected public APIs:
- TextInfo.ToLower,
- TextInfo.ToUpper

Below function are used from apple native functions:
- [uppercaseString](https://developer.apple.com/documentation/foundation/nsstring/1409855-uppercasestring)
- [lowercaseString](https://developer.apple.com/documentation/foundation/nsstring/1408467-lowercasestring)
- [uppercaseStringWithLocale](https://developer.apple.com/documentation/foundation/nsstring/1413316-uppercasestringwithlocale?language=objc)
- [lowercaseStringWithLocale](https://developer.apple.com/documentation/foundation/nsstring/1417298-lowercasestringwithlocale?language=objc)

Behavioural changes compared to ICU

- Capitalizing the German letter ß (sharp S) gives SS when using Apple native functions.

- Final sigma behavior correction:

ICU-based case change does not respect final-sigma rule, but hybrid does, so "ΒΌΛΟΣ" -> "βόλος", not "βόλοσ".


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<HybridGlobalization>true</HybridGlobalization>
</PropertyGroup>
<ItemGroup>
<!--<Compile Include="HybridMode.cs" />
<Compile Include="HybridMode.cs" />
<Compile Include="..\CultureInfo\CultureInfoNumberFormat.cs" />
<Compile Include="..\CultureInfo\CultureInfoNames.cs" />
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoData.cs" />
Expand Down Expand Up @@ -37,7 +37,7 @@
<Compile Include="..\CompareInfo\CompareInfoTests.IndexOf.cs" />
<Compile Include="..\CompareInfo\CompareInfoTests.LastIndexOf.cs" />
<Compile Include="..\CompareInfo\CompareInfoTests.IsPrefix.cs" />
<Compile Include="..\CompareInfo\CompareInfoTests.IsSuffix.cs" />-->
<Compile Include="..\CompareInfo\CompareInfoTests.IsSuffix.cs" />
<Compile Include="..\System\Globalization\TextInfoTests.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static IEnumerable<object[]> ToLower_TestData()
// we also don't preform.
// Greek Capital Letter Sigma (does not case to U+03C2 with "final sigma" rule).
yield return new object[] { cultureName, "\u03A3", "\u03C3" };
if (PlatformDetection.IsHybridGlobalizationOnBrowser || PlatformDetection.IsHybridGlobalizationOnOSX) // TODO check for OSX
if (PlatformDetection.IsHybridGlobalizationOnBrowser || PlatformDetection.IsHybridGlobalizationOnOSX)
{
// JS is using "final sigma" rule correctly - it's costly to unify it with ICU's behavior
yield return new object[] { cultureName, "O\u03A3", "o\u03C2" };
Expand Down Expand Up @@ -403,7 +403,8 @@ public static IEnumerable<object[]> ToUpper_TestData()
// we also don't preform.
// es-zed does not case to SS when uppercased.
yield return new object[] { cultureName, "\u00DF", "\u00DF" };
if (!PlatformDetection.IsHybridGlobalizationOnOSX) // TODO check for OSX
// Capitalizing the German letter ß (sharp S) gives SS on OSX
if (!PlatformDetection.IsHybridGlobalizationOnOSX)
{
yield return new object[] { cultureName, "stra\u00DFe", "STRA\u00DFE" };
if (!PlatformDetection.IsNlsGlobalization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ internal unsafe void ChangeCaseNative(char* src, int srcLen, char* dstBuffer, in
else
result = Interop.Globalization.ChangeCaseNative(_cultureName, _cultureName.Length, src, srcLen, dstBuffer, dstBufferCapacity, toUpper);

if (result == -1)
throw new Exception("Exception while case changing");
if (result != 0)
throw new Exception("Exception occured while case changing");
}
}
}
17 changes: 8 additions & 9 deletions src/native/libs/System.Globalization.Native/pal_collation.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l
* If the code point is not valid or a trail surrogate does not fit,
* then isError is set to true.
*
* @param s const UChar * string buffer
* @param s const uint16_t * string buffer
* @param i string offset, must be i<capacity
* @param capacity size of the string buffer
* @param c code point to append
* @param isError output UBool set to true if an error occurs, otherwise not modified
* @stable ICU 2.4
* @param isError output bool set to true if an error occurs, otherwise not modified
*/
#define Append(s, i, capacity, c, isError) UPRV_BLOCK_MACRO_BEGIN { \
#define Append(s, i, capacity, c, isError) { \
if((uint32_t)(c)<=0xffff) { \
(s)[(i)++]=(uint16_t)(c); \
} else if((uint32_t)(c)<=0x10ffff && (i)+1<(capacity)) { \
Expand All @@ -295,7 +294,7 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l
} else /* c>0x10ffff or not enough space */ { \
(isError)=true; \
} \
} UPRV_BLOCK_MACRO_END
}

/*
Function:
Expand All @@ -318,10 +317,10 @@ int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t
{
dstCodepoint = [result characterAtIndex:srcIdx];
Append(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == false);
srcIdx++;
//assert(isError == false && srcIdx == dstIdx);
}
return 0;
return isError ? -1 : 0;
}

/*
Expand All @@ -343,10 +342,10 @@ int32_t GlobalizationNative_ChangeCaseInvariantNative(const uint16_t* lpSrc, int
{
dstCodepoint = [result characterAtIndex:srcIdx];
Append(lpDst, dstIdx, cwDstLength, dstCodepoint, isError);
assert(isError == false);
srcIdx++;
//assert(isError == false && srcIdx == dstIdx);
}
return 0;
return isError ? -1 : 0;
}

#endif