2 * locales.c: Culture-sensitive handling
5 * Dick Porter (dick@ximian.com)
6 * Mohammad DAMT (mdamt@cdl2000.com)
7 * Marek Safar (marek.safar@gmail.com)
9 * Copyright 2003 Ximian, Inc (http://www.ximian.com)
10 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
11 * (C) 2003 PT Cakram Datalingga Duaribu http://www.cdl2000.com
12 * Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
19 #include <mono/metadata/debug-helpers.h>
20 #include <mono/metadata/object.h>
21 #include <mono/metadata/appdomain.h>
22 #include <mono/metadata/exception.h>
23 #include <mono/metadata/monitor.h>
24 #include <mono/metadata/locales.h>
25 #include <mono/metadata/culture-info.h>
26 #include <mono/metadata/culture-info-tables.h>
27 #include <mono/utils/bsearch.h>
29 #ifndef DISABLE_NORMALIZATION
30 #include <mono/metadata/normalization-tables.h>
34 #if defined(__APPLE__)
35 #include <CoreFoundation/CoreFoundation.h>
40 static gint32 string_invariant_compare_char (gunichar2 c1, gunichar2 c2,
42 static gint32 string_invariant_compare (MonoString *str1, gint32 off1,
43 gint32 len1, MonoString *str2,
44 gint32 off2, gint32 len2,
46 static MonoString *string_invariant_replace (MonoString *me,
48 MonoString *newValue);
49 static gint32 string_invariant_indexof (MonoString *source, gint32 sindex,
50 gint32 count, MonoString *value,
52 static gint32 string_invariant_indexof_char (MonoString *source, gint32 sindex,
53 gint32 count, gunichar2 value,
56 static const CultureInfoEntry* culture_info_entry_from_lcid (int lcid);
58 static const RegionInfoEntry* region_info_entry_from_lcid (int lcid);
61 culture_lcid_locator (const void *a, const void *b)
64 const CultureInfoEntry *bb = b;
66 return *lcid - bb->lcid;
70 culture_name_locator (const void *a, const void *b)
73 const CultureInfoNameEntry *bb = b;
76 ret = strcmp (aa, idx2string (bb->name));
82 region_name_locator (const void *a, const void *b)
85 const RegionInfoNameEntry *bb = b;
88 ret = strcmp (aa, idx2string (bb->name));
94 create_group_sizes_array (const gint *gs, gint ml)
99 for (i = 0; i < ml; i++) {
105 ret = mono_array_new_cached (mono_domain_get (),
106 mono_get_int32_class (), len);
108 for(i = 0; i < len; i++)
109 mono_array_set (ret, gint32, i, gs [i]);
115 create_names_array_idx (const guint16 *names, int ml)
124 domain = mono_domain_get ();
126 ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), ml);
128 for(i = 0; i < ml; i++)
129 mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
135 create_names_array_idx_dynamic (const guint16 *names, int ml)
144 domain = mono_domain_get ();
146 for (i = 0; i < ml; i++) {
152 ret = mono_array_new_cached (mono_domain_get (), mono_get_string_class (), len);
154 for(i = 0; i < len; i++)
155 mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
161 ves_icall_System_Globalization_CultureInfo_construct_datetime_format (MonoCultureInfo *this)
164 MonoDateTimeFormatInfo *datetime;
165 const DateTimeFormatEntry *dfe;
169 g_assert (this->datetime_index >= 0);
171 datetime = this->datetime_format;
172 dfe = &datetime_format_entries [this->datetime_index];
174 domain = mono_domain_get ();
176 datetime->readOnly = this->is_read_only;
177 MONO_OBJECT_SETREF (datetime, AbbreviatedDayNames, create_names_array_idx (dfe->abbreviated_day_names,
179 MONO_OBJECT_SETREF (datetime, AbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_names,
181 MONO_OBJECT_SETREF (datetime, AMDesignator, mono_string_new (domain, idx2string (dfe->am_designator)));
182 datetime->CalendarWeekRule = dfe->calendar_week_rule;
183 MONO_OBJECT_SETREF (datetime, DateSeparator, mono_string_new (domain, idx2string (dfe->date_separator)));
184 MONO_OBJECT_SETREF (datetime, DayNames, create_names_array_idx (dfe->day_names, NUM_DAYS));
185 MONO_OBJECT_SETREF (datetime, ShortestDayNames, create_names_array_idx (dfe->shortest_day_names, NUM_DAYS));
186 datetime->FirstDayOfWeek = dfe->first_day_of_week;
187 MONO_OBJECT_SETREF (datetime, LongDatePattern, mono_string_new (domain, idx2string (dfe->long_date_pattern)));
188 MONO_OBJECT_SETREF (datetime, LongTimePattern, mono_string_new (domain, idx2string (dfe->long_time_pattern)));
189 MONO_OBJECT_SETREF (datetime, MonthDayPattern, mono_string_new (domain, idx2string (dfe->month_day_pattern)));
190 MONO_OBJECT_SETREF (datetime, MonthNames, create_names_array_idx (dfe->month_names, NUM_MONTHS));
191 MONO_OBJECT_SETREF (datetime, PMDesignator, mono_string_new (domain, idx2string (dfe->pm_designator)));
192 MONO_OBJECT_SETREF (datetime, ShortDatePattern, mono_string_new (domain, idx2string (dfe->short_date_pattern)));
193 MONO_OBJECT_SETREF (datetime, ShortTimePattern, mono_string_new (domain, idx2string (dfe->short_time_pattern)));
194 MONO_OBJECT_SETREF (datetime, TimeSeparator, mono_string_new (domain, idx2string (dfe->time_separator)));
195 MONO_OBJECT_SETREF (datetime, YearMonthPattern, mono_string_new (domain, idx2string (dfe->year_month_pattern)));
196 MONO_OBJECT_SETREF (datetime, ShortDatePatterns, create_names_array_idx_dynamic (dfe->short_date_patterns,
197 NUM_SHORT_DATE_PATTERNS));
198 MONO_OBJECT_SETREF (datetime, LongDatePatterns, create_names_array_idx_dynamic (dfe->long_date_patterns,
199 NUM_LONG_DATE_PATTERNS));
200 MONO_OBJECT_SETREF (datetime, ShortTimePatterns, create_names_array_idx_dynamic (dfe->short_time_patterns,
201 NUM_SHORT_TIME_PATTERNS));
202 MONO_OBJECT_SETREF (datetime, LongTimePatterns, create_names_array_idx_dynamic (dfe->long_time_patterns,
203 NUM_LONG_TIME_PATTERNS));
204 MONO_OBJECT_SETREF (datetime, GenitiveMonthNames, create_names_array_idx (dfe->month_genitive_names, NUM_MONTHS));
205 MONO_OBJECT_SETREF (datetime, GenitiveAbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_genitive_names, NUM_MONTHS));
209 ves_icall_System_Globalization_CultureInfo_construct_number_format (MonoCultureInfo *this)
212 MonoNumberFormatInfo *number;
213 const NumberFormatEntry *nfe;
217 g_assert (this->number_format != 0);
218 if (this->number_index < 0)
221 number = this->number_format;
222 nfe = &number_format_entries [this->number_index];
224 domain = mono_domain_get ();
226 number->readOnly = this->is_read_only;
227 number->currencyDecimalDigits = nfe->currency_decimal_digits;
228 MONO_OBJECT_SETREF (number, currencyDecimalSeparator, mono_string_new (domain,
229 idx2string (nfe->currency_decimal_separator)));
230 MONO_OBJECT_SETREF (number, currencyGroupSeparator, mono_string_new (domain,
231 idx2string (nfe->currency_group_separator)));
232 MONO_OBJECT_SETREF (number, currencyGroupSizes, create_group_sizes_array (nfe->currency_group_sizes,
234 number->currencyNegativePattern = nfe->currency_negative_pattern;
235 number->currencyPositivePattern = nfe->currency_positive_pattern;
236 MONO_OBJECT_SETREF (number, currencySymbol, mono_string_new (domain, idx2string (nfe->currency_symbol)));
237 MONO_OBJECT_SETREF (number, naNSymbol, mono_string_new (domain, idx2string (nfe->nan_symbol)));
238 MONO_OBJECT_SETREF (number, negativeInfinitySymbol, mono_string_new (domain,
239 idx2string (nfe->negative_infinity_symbol)));
240 MONO_OBJECT_SETREF (number, negativeSign, mono_string_new (domain, idx2string (nfe->negative_sign)));
241 number->numberDecimalDigits = nfe->number_decimal_digits;
242 MONO_OBJECT_SETREF (number, numberDecimalSeparator, mono_string_new (domain,
243 idx2string (nfe->number_decimal_separator)));
244 MONO_OBJECT_SETREF (number, numberGroupSeparator, mono_string_new (domain, idx2string (nfe->number_group_separator)));
245 MONO_OBJECT_SETREF (number, numberGroupSizes, create_group_sizes_array (nfe->number_group_sizes,
247 number->numberNegativePattern = nfe->number_negative_pattern;
248 number->percentDecimalDigits = nfe->percent_decimal_digits;
249 MONO_OBJECT_SETREF (number, percentDecimalSeparator, mono_string_new (domain,
250 idx2string (nfe->percent_decimal_separator)));
251 MONO_OBJECT_SETREF (number, percentGroupSeparator, mono_string_new (domain,
252 idx2string (nfe->percent_group_separator)));
253 MONO_OBJECT_SETREF (number, percentGroupSizes, create_group_sizes_array (nfe->percent_group_sizes,
255 number->percentNegativePattern = nfe->percent_negative_pattern;
256 number->percentPositivePattern = nfe->percent_positive_pattern;
257 MONO_OBJECT_SETREF (number, percentSymbol, mono_string_new (domain, idx2string (nfe->percent_symbol)));
258 MONO_OBJECT_SETREF (number, perMilleSymbol, mono_string_new (domain, idx2string (nfe->per_mille_symbol)));
259 MONO_OBJECT_SETREF (number, positiveInfinitySymbol, mono_string_new (domain,
260 idx2string (nfe->positive_infinity_symbol)));
261 MONO_OBJECT_SETREF (number, positiveSign, mono_string_new (domain, idx2string (nfe->positive_sign)));
265 construct_culture (MonoCultureInfo *this, const CultureInfoEntry *ci)
267 MonoDomain *domain = mono_domain_get ();
269 this->lcid = ci->lcid;
270 MONO_OBJECT_SETREF (this, name, mono_string_new (domain, idx2string (ci->name)));
271 MONO_OBJECT_SETREF (this, englishname, mono_string_new (domain, idx2string (ci->englishname)));
272 MONO_OBJECT_SETREF (this, nativename, mono_string_new (domain, idx2string (ci->nativename)));
273 MONO_OBJECT_SETREF (this, win3lang, mono_string_new (domain, idx2string (ci->win3lang)));
274 MONO_OBJECT_SETREF (this, iso3lang, mono_string_new (domain, idx2string (ci->iso3lang)));
275 MONO_OBJECT_SETREF (this, iso2lang, mono_string_new (domain, idx2string (ci->iso2lang)));
277 // It's null for neutral cultures
278 if (ci->territory > 0)
279 MONO_OBJECT_SETREF (this, territory, mono_string_new (domain, idx2string (ci->territory)));
280 MONO_OBJECT_SETREF (this, native_calendar_names, create_names_array_idx (ci->native_calendar_names, NUM_CALENDARS));
281 this->parent_lcid = ci->parent_lcid;
282 this->datetime_index = ci->datetime_format_index;
283 this->number_index = ci->number_format_index;
284 this->calendar_type = ci->calendar_type;
285 this->text_info_data = &ci->text_info;
291 construct_region (MonoRegionInfo *this, const RegionInfoEntry *ri)
293 MonoDomain *domain = mono_domain_get ();
295 this->geo_id = ri->geo_id;
296 MONO_OBJECT_SETREF (this, iso2name, mono_string_new (domain, idx2string (ri->iso2name)));
297 MONO_OBJECT_SETREF (this, iso3name, mono_string_new (domain, idx2string (ri->iso3name)));
298 MONO_OBJECT_SETREF (this, win3name, mono_string_new (domain, idx2string (ri->win3name)));
299 MONO_OBJECT_SETREF (this, english_name, mono_string_new (domain, idx2string (ri->english_name)));
300 MONO_OBJECT_SETREF (this, native_name, mono_string_new (domain, idx2string (ri->native_name)));
301 MONO_OBJECT_SETREF (this, currency_symbol, mono_string_new (domain, idx2string (ri->currency_symbol)));
302 MONO_OBJECT_SETREF (this, iso_currency_symbol, mono_string_new (domain, idx2string (ri->iso_currency_symbol)));
303 MONO_OBJECT_SETREF (this, currency_english_name, mono_string_new (domain, idx2string (ri->currency_english_name)));
304 MONO_OBJECT_SETREF (this, currency_native_name, mono_string_new (domain, idx2string (ri->currency_native_name)));
310 construct_culture_from_specific_name (MonoCultureInfo *ci, gchar *name)
312 const CultureInfoEntry *entry;
313 const CultureInfoNameEntry *ne;
317 ne = mono_binary_search (name, culture_name_entries, NUM_CULTURE_ENTRIES,
318 sizeof (CultureInfoNameEntry), culture_name_locator);
323 entry = &culture_entries [ne->culture_entry_index];
326 return construct_culture (ci, entry);
331 static const CultureInfoEntry*
332 culture_info_entry_from_lcid (int lcid)
334 const CultureInfoEntry *ci;
336 ci = mono_binary_search (&lcid, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
341 static const RegionInfoEntry*
342 region_info_entry_from_lcid (int lcid)
344 const RegionInfoEntry *entry;
345 const CultureInfoEntry *ne;
349 ne = mono_binary_search (&lcid, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
354 entry = ®ion_entries [ne->region_entry_index];
359 #if defined (__APPLE__)
361 get_darwin_locale (void)
363 static gchar *darwin_locale = NULL;
364 CFLocaleRef locale = NULL;
365 CFStringRef locale_cfstr = NULL;
369 if (darwin_locale != NULL)
370 return g_strdup (darwin_locale);
372 locale = CFLocaleCopyCurrent ();
375 locale_cfstr = CFLocaleGetIdentifier (locale);
378 len = CFStringGetMaximumSizeForEncoding (CFStringGetLength (locale_cfstr), kCFStringEncodingMacRoman) + 1;
379 darwin_locale = (char *) malloc (len);
380 if (!CFStringGetCString (locale_cfstr, darwin_locale, len, kCFStringEncodingMacRoman)) {
381 free (darwin_locale);
383 darwin_locale = NULL;
387 for (i = 0; i < strlen (darwin_locale); i++)
388 if (darwin_locale [i] == '_')
389 darwin_locale [i] = '-';
395 return g_strdup (darwin_locale);
400 get_posix_locale (void)
404 locale = g_getenv ("LC_ALL");
405 if (locale == NULL) {
406 locale = g_getenv ("LANG");
408 locale = setlocale (LC_ALL, NULL);
413 /* Skip English-only locale 'C' */
414 if (strcmp (locale, "C") == 0)
417 return g_strdup (locale);
422 get_current_locale_name (void)
428 locale = g_win32_getlocale ();
429 #elif defined (__APPLE__)
430 locale = get_darwin_locale ();
432 locale = get_posix_locale ();
434 locale = get_posix_locale ();
440 p = strchr (locale, '.');
443 p = strchr (locale, '@');
447 ret = g_ascii_strdown (locale, -1);
454 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_current_locale (MonoCultureInfo *ci)
461 locale = get_current_locale_name ();
465 ret = construct_culture_from_specific_name (ci, locale);
467 ci->is_read_only = TRUE;
468 ci->use_user_override = TRUE;
474 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid (MonoCultureInfo *this,
477 const CultureInfoEntry *ci;
481 ci = culture_info_entry_from_lcid (lcid);
485 return construct_culture (this, ci);
489 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name (MonoCultureInfo *this,
492 const CultureInfoNameEntry *ne;
497 n = mono_string_to_utf8 (name);
498 ne = mono_binary_search (n, culture_name_entries, NUM_CULTURE_ENTRIES,
499 sizeof (CultureInfoNameEntry), culture_name_locator);
502 /*g_print ("ne (%s) is null\n", n);*/
508 return construct_culture (this, &culture_entries [ne->culture_entry_index]);
512 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name (MonoCultureInfo *ci,
520 locale = mono_string_to_utf8 (name);
521 ret = construct_culture_from_specific_name (ci, locale);
528 ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_lcid (MonoRegionInfo *this,
531 const RegionInfoEntry *ri;
535 ri = region_info_entry_from_lcid (lcid);
539 return construct_region (this, ri);
543 ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_name (MonoRegionInfo *this,
546 const RegionInfoNameEntry *ne;
551 n = mono_string_to_utf8 (name);
552 ne = mono_binary_search (n, region_name_entries, NUM_REGION_ENTRIES,
553 sizeof (RegionInfoNameEntry), region_name_locator);
556 /*g_print ("ne (%s) is null\n", n);*/
562 return construct_region (this, ®ion_entries [ne->region_entry_index]);
566 ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean neutral,
567 MonoBoolean specific, MonoBoolean installed)
571 MonoCultureInfo *culture;
573 const CultureInfoEntry *ci;
579 domain = mono_domain_get ();
582 for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
583 ci = &culture_entries [i];
584 is_neutral = ci->territory == 0;
585 if ((neutral && is_neutral) || (specific && !is_neutral))
589 class = mono_class_from_name (mono_get_corlib (),
590 "System.Globalization", "CultureInfo");
592 /* The InvariantCulture is not in culture_entries */
593 /* We reserve the first slot in the array for it */
597 ret = mono_array_new (domain, class, len);
604 mono_array_setref (ret, len++, NULL);
606 for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
607 ci = &culture_entries [i];
608 is_neutral = ci->territory == 0;
609 if ((neutral && is_neutral) || (specific && !is_neutral)) {
610 culture = (MonoCultureInfo *) mono_object_new (domain, class);
611 mono_runtime_object_init ((MonoObject *) culture);
612 construct_culture (culture, ci);
613 culture->use_user_override = TRUE;
614 mono_array_setref (ret, len++, culture);
621 void ves_icall_System_Globalization_CompareInfo_construct_compareinfo (MonoCompareInfo *comp, MonoString *locale)
623 /* Nothing to do here */
626 int ves_icall_System_Globalization_CompareInfo_internal_compare (MonoCompareInfo *this, MonoString *str1, gint32 off1, gint32 len1, MonoString *str2, gint32 off2, gint32 len2, gint32 options)
630 /* Do a normal ascii string compare, as we only know the
631 * invariant locale if we dont have ICU
633 return(string_invariant_compare (str1, off1, len1, str2, off2, len2,
637 void ves_icall_System_Globalization_CompareInfo_free_internal_collator (MonoCompareInfo *this)
639 /* Nothing to do here */
642 void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoCompareInfo *this, MonoSortKey *key, MonoString *source, gint32 options)
649 keylen=mono_string_length (source);
651 arr=mono_array_new (mono_domain_get (), mono_get_byte_class (),
653 for(i=0; i<keylen; i++) {
654 mono_array_set (arr, guint8, i, mono_string_chars (source)[i]);
657 MONO_OBJECT_SETREF (key, key, arr);
660 int ves_icall_System_Globalization_CompareInfo_internal_index (MonoCompareInfo *this, MonoString *source, gint32 sindex, gint32 count, MonoString *value, gint32 options, MonoBoolean first)
664 return(string_invariant_indexof (source, sindex, count, value, first));
667 int ves_icall_System_Globalization_CompareInfo_internal_index_char (MonoCompareInfo *this, MonoString *source, gint32 sindex, gint32 count, gunichar2 value, gint32 options, MonoBoolean first)
671 return(string_invariant_indexof_char (source, sindex, count, value,
675 int ves_icall_System_Threading_Thread_current_lcid (void)
683 MonoString *ves_icall_System_String_InternalReplace_Str_Comp (MonoString *this, MonoString *old, MonoString *new, MonoCompareInfo *comp)
687 /* Do a normal ascii string compare and replace, as we only
688 * know the invariant locale if we dont have ICU
690 return(string_invariant_replace (this, old, new));
693 static gint32 string_invariant_compare_char (gunichar2 c1, gunichar2 c2,
698 /* Ordinal can not be mixed with other options, and must return the difference, not only -1, 0, 1 */
699 if (options & CompareOptions_Ordinal)
700 return (gint32) c1 - c2;
702 if (options & CompareOptions_IgnoreCase) {
703 GUnicodeType c1type, c2type;
705 c1type = g_unichar_type (c1);
706 c2type = g_unichar_type (c2);
708 result = (gint32) (c1type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c1) : c1) -
709 (c2type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c2) : c2);
712 * No options. Kana, symbol and spacing options don't
713 * apply to the invariant culture.
717 * FIXME: here we must use the information from c1type and c2type
718 * to find out the proper collation, even on the InvariantCulture, the
719 * sorting is not done by computing the unicode values, but their
722 result = (gint32) c1 - c2;
725 return ((result < 0) ? -1 : (result > 0) ? 1 : 0);
728 static gint32 string_invariant_compare (MonoString *str1, gint32 off1,
729 gint32 len1, MonoString *str2,
730 gint32 off2, gint32 len2,
733 /* c translation of C# code from old string.cs.. :) */
746 ustr1 = mono_string_chars(str1)+off1;
747 ustr2 = mono_string_chars(str2)+off2;
751 for (pos = 0; pos != length; pos++) {
752 if (pos >= len1 || pos >= len2)
755 charcmp = string_invariant_compare_char(ustr1[pos], ustr2[pos],
762 /* the lesser wins, so if we have looped until length we just
763 * need to check the last char
766 return(string_invariant_compare_char(ustr1[pos - 1],
767 ustr2[pos - 1], options));
770 /* Test if one of the strings has been compared to the end */
777 } else if (pos >= len2) {
781 /* if not, check our last char only.. (can this happen?) */
782 return(string_invariant_compare_char(ustr1[pos], ustr2[pos], options));
785 static MonoString *string_invariant_replace (MonoString *me,
786 MonoString *oldValue,
787 MonoString *newValue)
791 gunichar2 *dest=NULL; /* shut gcc up */
793 gunichar2 *newstr=NULL; /* shut gcc up here too */
804 oldstr = mono_string_chars(oldValue);
805 oldstrlen = mono_string_length(oldValue);
807 if (NULL != newValue) {
808 newstr = mono_string_chars(newValue);
809 newstrlen = mono_string_length(newValue);
813 src = mono_string_chars(me);
814 srclen = mono_string_length(me);
816 if (oldstrlen != newstrlen) {
818 while (i <= srclen - oldstrlen) {
819 if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) {
828 newsize = srclen + ((newstrlen - oldstrlen) * occurr);
835 if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) {
837 ret = mono_string_new_size( mono_domain_get (), newsize);
838 dest = mono_string_chars(ret);
839 memcpy (dest, src, i * sizeof(gunichar2));
842 memcpy(dest + destpos, newstr, newstrlen * sizeof(gunichar2));
843 destpos += newstrlen;
847 } else if (ret != NULL) {
848 dest[destpos] = src[i];
860 static gint32 string_invariant_indexof (MonoString *source, gint32 sindex,
861 gint32 count, MonoString *value,
869 lencmpstr = mono_string_length(value);
871 src = mono_string_chars(source);
872 cmpstr = mono_string_chars(value);
876 for(pos=sindex;pos <= sindex+count;pos++) {
877 for(i=0;src[pos+i]==cmpstr[i];) {
886 for(pos=sindex-lencmpstr+1;pos>sindex-count;pos--) {
887 if(memcmp (src+pos, cmpstr,
888 lencmpstr*sizeof(gunichar2))==0) {
897 static gint32 string_invariant_indexof_char (MonoString *source, gint32 sindex,
898 gint32 count, gunichar2 value,
904 src = mono_string_chars(source);
906 for (pos = sindex; pos != count + sindex; pos++) {
907 if (src [pos] == value) {
914 for (pos = sindex; pos > sindex - count; pos--) {
915 if (src [pos] == value)
923 void load_normalization_resource (guint8 **argProps,
924 guint8 **argMappedChars,
925 guint8 **argCharMapIndex,
926 guint8 **argHelperIndex,
927 guint8 **argMapIdxToComposite,
928 guint8 **argCombiningClass)
930 #ifdef DISABLE_NORMALIZATION
931 mono_raise_exception (mono_get_exception_not_supported ("This runtime has been compiled without string normalization support."));
933 *argProps = (guint8*)props;
934 *argMappedChars = (guint8*) mappedChars;
935 *argCharMapIndex = (guint8*) charMapIndex;
936 *argHelperIndex = (guint8*) helperIndex;
937 *argMapIdxToComposite = (guint8*) mapIdxToComposite;
938 *argCombiningClass = (guint8*)combiningClass;