@@ -8,7 +8,6 @@ namespace Jint.Native.Intl;
88// We use DllImport to bind directly to its functions (e.g. uloc_toLanguageTag) so we can
99// reuse the OS-provided ICU implementation instead of reimplementing the spec in C#.
1010// The wrapper below converts managed strings to UTF-8, calls ICU, and returns the canonical tag.
11-
1211internal static class ICU
1312{
1413 private const string MacLib = "/usr/lib/libicucore.dylib" ;
@@ -48,8 +47,6 @@ public enum UErrorCode : int
4847 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
4948 public static string PtrToAnsiString ( IntPtr p ) => Marshal . PtrToStringAnsi ( p ) ! ;
5049
51-
52- // Older runtimes: pass IntPtr and pin a UTF-8 buffer manually.
5350 [ DllImport ( UcLib , CallingConvention = CallingConvention . Cdecl , EntryPoint = "uloc_toLanguageTag" ) ]
5451 private static extern unsafe int uloc_toLanguageTag_ptr (
5552 byte * localeIdUtf8 , // const char* (UTF-8)
@@ -77,15 +74,15 @@ private static extern unsafe int uloc_forLanguageTag_ptr(
7774 out int parsedLength ,
7875 ref UErrorCode err ) ;
7976
80- public static unsafe int uloc_forLanguageTag (
81- string langtag , byte [ ] localeId , int localeIdCapacity , out int parsedLength , ref UErrorCode err )
77+ public static unsafe int uloc_forLanguageTag ( string langtag , byte [ ] localeId , int localeIdCapacity , out int parsedLength , ref UErrorCode err )
8278 {
8379 var inBytes = System . Text . Encoding . UTF8 . GetBytes ( langtag + "\0 " ) ;
8480 fixed ( byte * p = inBytes )
8581 {
8682 return uloc_forLanguageTag_ptr ( p , localeId , localeIdCapacity , out parsedLength , ref err ) ;
8783 }
8884 }
85+
8986 [ DllImport ( UcLib , CallingConvention = CallingConvention . Cdecl , EntryPoint = "uloc_canonicalize" ) ]
9087 private static extern unsafe int uloc_canonicalize_ptr (
9188 byte * localeIdUtf8 , // const char* (UTF-8, NUL-terminated)
0 commit comments