2 * locales.c: Culture-sensitive handling
5 * Dick Porter (dick@ximian.com)
6 * Mohammad DAMT (mdamt@cdl2000.com)
8 * (C) 2003 Ximian, Inc.
9 * (C) 2003 PT Cakram Datalingga Duaribu http://www.cdl2000.com
16 #include <mono/metadata/debug-helpers.h>
17 #include <mono/metadata/object.h>
18 #include <mono/metadata/appdomain.h>
19 #include <mono/metadata/exception.h>
20 #include <mono/metadata/monitor.h>
21 #include <mono/metadata/locales.h>
22 #include <mono/metadata/culture-info.h>
23 #include <mono/metadata/culture-info-tables.h>
24 #include <mono/metadata/normalization-tables.h>
31 static gint32 string_invariant_compare_char (gunichar2 c1, gunichar2 c2,
33 static gint32 string_invariant_compare (MonoString *str1, gint32 off1,
34 gint32 len1, MonoString *str2,
35 gint32 off2, gint32 len2,
37 static MonoString *string_invariant_replace (MonoString *me,
39 MonoString *newValue);
40 static gint32 string_invariant_indexof (MonoString *source, gint32 sindex,
41 gint32 count, MonoString *value,
43 static gint32 string_invariant_indexof_char (MonoString *source, gint32 sindex,
44 gint32 count, gunichar2 value,
47 static const CultureInfoEntry* culture_info_entry_from_lcid (int lcid);
49 static const RegionInfoEntry* region_info_entry_from_lcid (int lcid);
52 culture_lcid_locator (const void *a, const void *b)
54 const CultureInfoEntry *aa = a;
55 const CultureInfoEntry *bb = b;
57 return (aa->lcid - bb->lcid);
61 region_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 (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 for (i = 0; i < ml; i++) {
132 ret = mono_array_new (mono_domain_get (), mono_get_string_class (), len);
134 for(i = 0; i < len; i++)
135 mono_array_setref (ret, i, mono_string_new (domain, idx2string (names [i])));
141 ves_icall_System_Globalization_CultureInfo_construct_datetime_format (MonoCultureInfo *this)
144 MonoDateTimeFormatInfo *datetime;
145 const DateTimeFormatEntry *dfe;
149 g_assert (this->datetime_index >= 0);
151 datetime = this->datetime_format;
152 dfe = &datetime_format_entries [this->datetime_index];
154 domain = mono_domain_get ();
156 datetime->readOnly = this->is_read_only;
157 MONO_OBJECT_SETREF (datetime, AbbreviatedDayNames, create_names_array_idx (dfe->abbreviated_day_names,
159 MONO_OBJECT_SETREF (datetime, AbbreviatedMonthNames, create_names_array_idx (dfe->abbreviated_month_names,
161 MONO_OBJECT_SETREF (datetime, AMDesignator, mono_string_new (domain, idx2string (dfe->am_designator)));
162 datetime->CalendarWeekRule = dfe->calendar_week_rule;
163 MONO_OBJECT_SETREF (datetime, DateSeparator, mono_string_new (domain, idx2string (dfe->date_separator)));
164 MONO_OBJECT_SETREF (datetime, DayNames, create_names_array_idx (dfe->day_names, NUM_DAYS));
165 datetime->FirstDayOfWeek = dfe->first_day_of_week;
166 MONO_OBJECT_SETREF (datetime, FullDateTimePattern, mono_string_new (domain, idx2string (dfe->full_date_time_pattern)));
167 MONO_OBJECT_SETREF (datetime, LongDatePattern, mono_string_new (domain, idx2string (dfe->long_date_pattern)));
168 MONO_OBJECT_SETREF (datetime, LongTimePattern, mono_string_new (domain, idx2string (dfe->long_time_pattern)));
169 MONO_OBJECT_SETREF (datetime, MonthDayPattern, mono_string_new (domain, idx2string (dfe->month_day_pattern)));
170 MONO_OBJECT_SETREF (datetime, MonthNames, create_names_array_idx (dfe->month_names, NUM_MONTHS));
171 MONO_OBJECT_SETREF (datetime, PMDesignator, mono_string_new (domain, idx2string (dfe->pm_designator)));
172 MONO_OBJECT_SETREF (datetime, ShortDatePattern, mono_string_new (domain, idx2string (dfe->short_date_pattern)));
173 MONO_OBJECT_SETREF (datetime, ShortTimePattern, mono_string_new (domain, idx2string (dfe->short_time_pattern)));
174 MONO_OBJECT_SETREF (datetime, TimeSeparator, mono_string_new (domain, idx2string (dfe->time_separator)));
175 MONO_OBJECT_SETREF (datetime, YearMonthPattern, mono_string_new (domain, idx2string (dfe->year_month_pattern)));
176 MONO_OBJECT_SETREF (datetime, ShortDatePatterns, create_names_array_idx (dfe->short_date_patterns,
177 NUM_SHORT_DATE_PATTERNS));
178 MONO_OBJECT_SETREF (datetime, LongDatePatterns, create_names_array_idx (dfe->long_date_patterns,
179 NUM_LONG_DATE_PATTERNS));
180 MONO_OBJECT_SETREF (datetime, ShortTimePatterns, create_names_array_idx (dfe->short_time_patterns,
181 NUM_SHORT_TIME_PATTERNS));
182 MONO_OBJECT_SETREF (datetime, LongTimePatterns, create_names_array_idx (dfe->long_time_patterns,
183 NUM_LONG_TIME_PATTERNS));
188 ves_icall_System_Globalization_CultureInfo_construct_number_format (MonoCultureInfo *this)
191 MonoNumberFormatInfo *number;
192 const NumberFormatEntry *nfe;
196 g_assert (this->number_format != 0);
198 number = this->number_format;
199 nfe = &number_format_entries [this->number_index];
201 domain = mono_domain_get ();
203 number->readOnly = this->is_read_only;
204 number->currencyDecimalDigits = nfe->currency_decimal_digits;
205 MONO_OBJECT_SETREF (number, currencyDecimalSeparator, mono_string_new (domain,
206 idx2string (nfe->currency_decimal_separator)));
207 MONO_OBJECT_SETREF (number, currencyGroupSeparator, mono_string_new (domain,
208 idx2string (nfe->currency_group_separator)));
209 MONO_OBJECT_SETREF (number, currencyGroupSizes, create_group_sizes_array (nfe->currency_group_sizes,
211 number->currencyNegativePattern = nfe->currency_negative_pattern;
212 number->currencyPositivePattern = nfe->currency_positive_pattern;
213 MONO_OBJECT_SETREF (number, currencySymbol, mono_string_new (domain, idx2string (nfe->currency_symbol)));
214 MONO_OBJECT_SETREF (number, naNSymbol, mono_string_new (domain, idx2string (nfe->nan_symbol)));
215 MONO_OBJECT_SETREF (number, negativeInfinitySymbol, mono_string_new (domain,
216 idx2string (nfe->negative_infinity_symbol)));
217 MONO_OBJECT_SETREF (number, negativeSign, mono_string_new (domain, idx2string (nfe->negative_sign)));
218 number->numberDecimalDigits = nfe->number_decimal_digits;
219 MONO_OBJECT_SETREF (number, numberDecimalSeparator, mono_string_new (domain,
220 idx2string (nfe->number_decimal_separator)));
221 MONO_OBJECT_SETREF (number, numberGroupSeparator, mono_string_new (domain, idx2string (nfe->number_group_separator)));
222 MONO_OBJECT_SETREF (number, numberGroupSizes, create_group_sizes_array (nfe->number_group_sizes,
224 number->numberNegativePattern = nfe->number_negative_pattern;
225 number->percentDecimalDigits = nfe->percent_decimal_digits;
226 MONO_OBJECT_SETREF (number, percentDecimalSeparator, mono_string_new (domain,
227 idx2string (nfe->percent_decimal_separator)));
228 MONO_OBJECT_SETREF (number, percentGroupSeparator, mono_string_new (domain,
229 idx2string (nfe->percent_group_separator)));
230 MONO_OBJECT_SETREF (number, percentGroupSizes, create_group_sizes_array (nfe->percent_group_sizes,
232 number->percentNegativePattern = nfe->percent_negative_pattern;
233 number->percentPositivePattern = nfe->percent_positive_pattern;
234 MONO_OBJECT_SETREF (number, percentSymbol, mono_string_new (domain, idx2string (nfe->percent_symbol)));
235 MONO_OBJECT_SETREF (number, perMilleSymbol, mono_string_new (domain, idx2string (nfe->per_mille_symbol)));
236 MONO_OBJECT_SETREF (number, positiveInfinitySymbol, mono_string_new (domain,
237 idx2string (nfe->positive_infinity_symbol)));
238 MONO_OBJECT_SETREF (number, positiveSign, mono_string_new (domain, idx2string (nfe->positive_sign)));
242 construct_culture (MonoCultureInfo *this, const CultureInfoEntry *ci)
244 MonoDomain *domain = mono_domain_get ();
246 this->lcid = ci->lcid;
247 MONO_OBJECT_SETREF (this, name, mono_string_new (domain, idx2string (ci->name)));
248 MONO_OBJECT_SETREF (this, icu_name, mono_string_new (domain, idx2string (ci->icu_name)));
249 MONO_OBJECT_SETREF (this, displayname, mono_string_new (domain, idx2string (ci->displayname)));
250 MONO_OBJECT_SETREF (this, englishname, mono_string_new (domain, idx2string (ci->englishname)));
251 MONO_OBJECT_SETREF (this, nativename, mono_string_new (domain, idx2string (ci->nativename)));
252 MONO_OBJECT_SETREF (this, win3lang, mono_string_new (domain, idx2string (ci->win3lang)));
253 MONO_OBJECT_SETREF (this, iso3lang, mono_string_new (domain, idx2string (ci->iso3lang)));
254 MONO_OBJECT_SETREF (this, iso2lang, mono_string_new (domain, idx2string (ci->iso2lang)));
255 MONO_OBJECT_SETREF (this, territory, mono_string_new (domain, idx2string (ci->territory)));
256 this->parent_lcid = ci->parent_lcid;
257 this->specific_lcid = ci->specific_lcid;
258 this->datetime_index = ci->datetime_format_index;
259 this->number_index = ci->number_format_index;
260 this->calendar_data = ci->calendar_data;
261 this->text_info_data = &ci->text_info;
267 construct_region (MonoRegionInfo *this, const RegionInfoEntry *ri)
269 MonoDomain *domain = mono_domain_get ();
271 this->region_id = ri->region_id;
272 MONO_OBJECT_SETREF (this, iso2name, mono_string_new (domain, idx2string (ri->iso2name)));
273 MONO_OBJECT_SETREF (this, iso3name, mono_string_new (domain, idx2string (ri->iso3name)));
274 MONO_OBJECT_SETREF (this, win3name, mono_string_new (domain, idx2string (ri->win3name)));
275 MONO_OBJECT_SETREF (this, english_name, mono_string_new (domain, idx2string (ri->english_name)));
276 MONO_OBJECT_SETREF (this, currency_symbol, mono_string_new (domain, idx2string (ri->currency_symbol)));
277 MONO_OBJECT_SETREF (this, iso_currency_symbol, mono_string_new (domain, idx2string (ri->iso_currency_symbol)));
278 MONO_OBJECT_SETREF (this, currency_english_name, mono_string_new (domain, idx2string (ri->currency_english_name)));
284 construct_culture_from_specific_name (MonoCultureInfo *ci, gchar *name)
286 const CultureInfoEntry *entry;
287 const CultureInfoNameEntry *ne;
291 ne = bsearch (name, culture_name_entries, NUM_CULTURE_ENTRIES,
292 sizeof (CultureInfoNameEntry), culture_name_locator);
297 entry = &culture_entries [ne->culture_entry_index];
299 /* try avoiding another lookup, often the culture is its own specific culture */
300 if (entry->lcid != entry->specific_lcid)
301 entry = culture_info_entry_from_lcid (entry->specific_lcid);
303 return construct_culture (ci, entry);
306 static const CultureInfoEntry*
307 culture_info_entry_from_lcid (int lcid)
309 const CultureInfoEntry *ci;
310 CultureInfoEntry key;
313 ci = bsearch (&key, culture_entries, NUM_CULTURE_ENTRIES, sizeof (CultureInfoEntry), culture_lcid_locator);
318 static const RegionInfoEntry*
319 region_info_entry_from_lcid (int lcid)
321 const RegionInfoEntry *entry;
322 const CultureInfoEntry *ne;
326 ne = bsearch (&lcid, culture_entries, NUM_CULTURE_ENTRIES,
327 sizeof (CultureInfoEntry), region_lcid_locator);
332 entry = ®ion_entries [ne->region_entry_index];
338 * The following two methods are modified from the ICU source code. (http://oss.software.ibm.com/icu)
339 * Copyright (c) 1995-2003 International Business Machines Corporation and others
340 * All rights reserved.
343 get_posix_locale (void)
345 const gchar* posix_locale = NULL;
347 posix_locale = g_getenv("LC_ALL");
348 if (posix_locale == 0) {
349 posix_locale = g_getenv("LANG");
350 if (posix_locale == 0) {
351 posix_locale = setlocale(LC_ALL, NULL);
355 if (posix_locale == NULL)
358 if ((strcmp ("C", posix_locale) == 0) || (strchr (posix_locale, ' ') != NULL)
359 || (strchr (posix_locale, '/') != NULL)) {
361 * HPUX returns 'C C C C C C C'
362 * Solaris can return /en_US/C/C/C/C/C on the second try.
363 * Maybe we got some garbage.
368 return g_strdup (posix_locale);
372 get_current_locale_name (void)
375 gchar *corrected = NULL;
379 #ifdef PLATFORM_WIN32
380 locale = g_win32_getlocale ();
382 locale = get_posix_locale ();
388 if ((p = strchr (locale, '.')) != NULL) {
389 /* assume new locale can't be larger than old one? */
390 corrected = malloc (strlen (locale));
391 strncpy (corrected, locale, p - locale);
392 corrected [p - locale] = 0;
394 /* do not copy after the @ */
395 if ((p = strchr (corrected, '@')) != NULL)
396 corrected [p - corrected] = 0;
399 /* Note that we scan the *uncorrected* ID. */
400 if ((p = strrchr (locale, '@')) != NULL) {
403 * In Mono we dont handle the '@' modifier because we do
404 * not have any cultures that use it. We just trim it
405 * off of the end of the name.
408 if (corrected == NULL) {
409 corrected = malloc (strlen (locale));
410 strncpy (corrected, locale, p - locale);
411 corrected [p - locale] = 0;
415 if (corrected == NULL)
420 if ((c = strchr (corrected, '_')) != NULL)
423 g_strdown (corrected);
429 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_current_locale (MonoCultureInfo *ci)
436 locale = get_current_locale_name ();
440 ret = construct_culture_from_specific_name (ci, locale);
442 ci->is_read_only = TRUE;
443 ci->use_user_override = TRUE;
449 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid (MonoCultureInfo *this,
452 const CultureInfoEntry *ci;
456 ci = culture_info_entry_from_lcid (lcid);
460 return construct_culture (this, ci);
464 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name (MonoCultureInfo *this,
467 const CultureInfoNameEntry *ne;
472 n = mono_string_to_utf8 (name);
473 ne = bsearch (n, culture_name_entries, NUM_CULTURE_ENTRIES,
474 sizeof (CultureInfoNameEntry), culture_name_locator);
477 /*g_print ("ne (%s) is null\n", n);*/
483 return construct_culture (this, &culture_entries [ne->culture_entry_index]);
487 ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name (MonoCultureInfo *ci,
495 locale = mono_string_to_utf8 (name);
496 ret = construct_culture_from_specific_name (ci, locale);
503 ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_lcid (MonoRegionInfo *this,
506 const RegionInfoEntry *ri;
510 ri = region_info_entry_from_lcid (lcid);
514 return construct_region (this, ri);
518 ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_name (MonoRegionInfo *this,
521 const RegionInfoNameEntry *ne;
526 n = mono_string_to_utf8 (name);
527 ne = bsearch (n, region_name_entries, NUM_REGION_ENTRIES,
528 sizeof (RegionInfoNameEntry), region_name_locator);
531 /*g_print ("ne (%s) is null\n", n);*/
537 return construct_region (this, ®ion_entries [ne->region_entry_index]);
541 ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean neutral,
542 MonoBoolean specific, MonoBoolean installed)
546 MonoCultureInfo *culture;
548 const CultureInfoEntry *ci;
554 domain = mono_domain_get ();
557 for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
558 ci = &culture_entries [i];
559 is_neutral = ((ci->lcid & 0xff00) == 0 || ci->specific_lcid == 0);
560 if ((neutral && is_neutral) || (specific && !is_neutral))
564 class = mono_class_from_name (mono_get_corlib (),
565 "System.Globalization", "CultureInfo");
567 /* The InvariantCulture is not in culture_entries */
568 /* We reserve the first slot in the array for it */
572 ret = mono_array_new (domain, class, len);
579 mono_array_setref (ret, len++, NULL);
581 for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
582 ci = &culture_entries [i];
583 is_neutral = ((ci->lcid & 0xff00) == 0 || ci->specific_lcid == 0);
584 if ((neutral && is_neutral) || (specific && !is_neutral)) {
585 culture = (MonoCultureInfo *) mono_object_new (domain, class);
586 mono_runtime_object_init ((MonoObject *) culture);
587 construct_culture (culture, ci);
588 culture->use_user_override = TRUE;
589 mono_array_setref (ret, len++, culture);
597 * ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral:
599 * Set is_neutral and return TRUE if the culture is found. If it is not found return FALSE.
602 ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral (gint lcid, MonoBoolean *is_neutral)
604 const CultureInfoEntry *entry;
608 entry = culture_info_entry_from_lcid (lcid);
613 *is_neutral = (entry->specific_lcid == 0);
618 void ves_icall_System_Globalization_CompareInfo_construct_compareinfo (MonoCompareInfo *comp, MonoString *locale)
620 /* Nothing to do here */
623 int ves_icall_System_Globalization_CompareInfo_internal_compare (MonoCompareInfo *this, MonoString *str1, gint32 off1, gint32 len1, MonoString *str2, gint32 off2, gint32 len2, gint32 options)
627 /* Do a normal ascii string compare, as we only know the
628 * invariant locale if we dont have ICU
630 return(string_invariant_compare (str1, off1, len1, str2, off2, len2,
634 void ves_icall_System_Globalization_CompareInfo_free_internal_collator (MonoCompareInfo *this)
636 /* Nothing to do here */
639 void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoCompareInfo *this, MonoSortKey *key, MonoString *source, gint32 options)
646 keylen=mono_string_length (source);
648 arr=mono_array_new (mono_domain_get (), mono_get_byte_class (),
650 for(i=0; i<keylen; i++) {
651 mono_array_set (arr, guint8, i, mono_string_chars (source)[i]);
654 MONO_OBJECT_SETREF (key, key, arr);
657 int ves_icall_System_Globalization_CompareInfo_internal_index (MonoCompareInfo *this, MonoString *source, gint32 sindex, gint32 count, MonoString *value, gint32 options, MonoBoolean first)
661 return(string_invariant_indexof (source, sindex, count, value, first));
664 int ves_icall_System_Globalization_CompareInfo_internal_index_char (MonoCompareInfo *this, MonoString *source, gint32 sindex, gint32 count, gunichar2 value, gint32 options, MonoBoolean first)
668 return(string_invariant_indexof_char (source, sindex, count, value,
672 int ves_icall_System_Threading_Thread_current_lcid (void)
680 MonoString *ves_icall_System_String_InternalReplace_Str_Comp (MonoString *this, MonoString *old, MonoString *new, MonoCompareInfo *comp)
684 /* Do a normal ascii string compare and replace, as we only
685 * know the invariant locale if we dont have ICU
687 return(string_invariant_replace (this, old, new));
690 static gint32 string_invariant_compare_char (gunichar2 c1, gunichar2 c2,
694 GUnicodeType c1type, c2type;
696 /* Ordinal can not be mixed with other options, and must return the difference, not only -1, 0, 1 */
697 if (options & CompareOptions_Ordinal)
698 return (gint32) c1 - c2;
700 c1type = g_unichar_type (c1);
701 c2type = g_unichar_type (c2);
703 if (options & CompareOptions_IgnoreCase) {
704 result = (gint32) (c1type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c1) : c1) -
705 (c2type != G_UNICODE_LOWERCASE_LETTER ? g_unichar_tolower(c2) : c2);
708 * No options. Kana, symbol and spacing options don't
709 * apply to the invariant culture.
713 * FIXME: here we must use the information from c1type and c2type
714 * to find out the proper collation, even on the InvariantCulture, the
715 * sorting is not done by computing the unicode values, but their
718 result = (gint32) c1 - c2;
721 return ((result < 0) ? -1 : (result > 0) ? 1 : 0);
724 static gint32 string_invariant_compare (MonoString *str1, gint32 off1,
725 gint32 len1, MonoString *str2,
726 gint32 off2, gint32 len2,
729 /* c translation of C# code from old string.cs.. :) */
742 ustr1 = mono_string_chars(str1)+off1;
743 ustr2 = mono_string_chars(str2)+off2;
747 for (pos = 0; pos != length; pos++) {
748 if (pos >= len1 || pos >= len2)
751 charcmp = string_invariant_compare_char(ustr1[pos], ustr2[pos],
758 /* the lesser wins, so if we have looped until length we just
759 * need to check the last char
762 return(string_invariant_compare_char(ustr1[pos - 1],
763 ustr2[pos - 1], options));
766 /* Test if one of the strings has been compared to the end */
773 } else if (pos >= len2) {
777 /* if not, check our last char only.. (can this happen?) */
778 return(string_invariant_compare_char(ustr1[pos], ustr2[pos], options));
781 static MonoString *string_invariant_replace (MonoString *me,
782 MonoString *oldValue,
783 MonoString *newValue)
787 gunichar2 *dest=NULL; /* shut gcc up */
789 gunichar2 *newstr=NULL; /* shut gcc up here too */
800 oldstr = mono_string_chars(oldValue);
801 oldstrlen = mono_string_length(oldValue);
803 if (NULL != newValue) {
804 newstr = mono_string_chars(newValue);
805 newstrlen = mono_string_length(newValue);
809 src = mono_string_chars(me);
810 srclen = mono_string_length(me);
812 if (oldstrlen != newstrlen) {
814 while (i <= srclen - oldstrlen) {
815 if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) {
824 newsize = srclen + ((newstrlen - oldstrlen) * occurr);
831 if (0 == memcmp(src + i, oldstr, oldstrlen * sizeof(gunichar2))) {
833 ret = mono_string_new_size( mono_domain_get (), newsize);
834 dest = mono_string_chars(ret);
835 memcpy (dest, src, i * sizeof(gunichar2));
838 memcpy(dest + destpos, newstr, newstrlen * sizeof(gunichar2));
839 destpos += newstrlen;
843 } else if (ret != NULL) {
844 dest[destpos] = src[i];
856 static gint32 string_invariant_indexof (MonoString *source, gint32 sindex,
857 gint32 count, MonoString *value,
865 lencmpstr = mono_string_length(value);
867 src = mono_string_chars(source);
868 cmpstr = mono_string_chars(value);
872 for(pos=sindex;pos <= sindex+count;pos++) {
873 for(i=0;src[pos+i]==cmpstr[i];) {
882 for(pos=sindex-lencmpstr+1;pos>sindex-count;pos--) {
883 if(memcmp (src+pos, cmpstr,
884 lencmpstr*sizeof(gunichar2))==0) {
893 static gint32 string_invariant_indexof_char (MonoString *source, gint32 sindex,
894 gint32 count, gunichar2 value,
900 src = mono_string_chars(source);
902 for (pos = sindex; pos != count + sindex; pos++) {
903 if (src [pos] == value) {
910 for (pos = sindex; pos > sindex - count; pos--) {
911 if (src [pos] == value)
919 void load_normalization_resource (guint8 **argProps,
920 guint8 **argMappedChars,
921 guint8 **argCharMapIndex,
922 guint8 **argHelperIndex,
923 guint8 **argMapIdxToComposite,
924 guint8 **argCombiningClass)
926 *argProps = (guint8*)props;
927 *argMappedChars = (guint8*) mappedChars;
928 *argCharMapIndex = (guint8*) charMapIndex;
929 *argHelperIndex = (guint8*) helperIndex;
930 *argMapIdxToComposite = (guint8*) mapIdxToComposite;
931 *argCombiningClass = (guint8*)combiningClass;