private static int compare_char(char a, char b, System.Globalization.CompareOptions options) { int result; if ((options & System.Globalization.CompareOptions.Ordinal) == System.Globalization.CompareOptions.Ordinal) { return((int)a - (int)b); } if ((options & System.Globalization.CompareOptions.IgnoreCase) == System.Globalization.CompareOptions.IgnoreCase) { char al = char.ToLower(a); char bl = char.ToLower(b); result = (int)al - (int)bl; } else { result = (int)a - (int)b; } if (result < 0) { return(-1); } if (result > 0) { return(1); } return(0); }
public static int Compare(string strA, string strB, system.globalization.CultureInfo culture, System.Globalization.CompareOptions options) { return(system.globalization.CompareInfo.CompareString(strA, strB, options, culture.CompareInfo)); }
private static int Compare(string strA, int indexA, string strB, int indexB, int length, system.globalization.CompareInfo compareInfo, System.Globalization.CompareOptions compareOptions) { int lengthA = length; if (strA != null) { int maxlenA = ((java.lang.String)(object) strA).length() - indexA; if (maxlenA < lengthA) { lengthA = maxlenA; } } int lengthB = length; if (strB != null) { int maxlenB = ((java.lang.String)(object) strB).length() - indexB; if (maxlenB < lengthB) { lengthB = maxlenB; } } return(compareInfo.Compare( strA, indexA, lengthA, strB, indexB, lengthB, compareOptions)); }
/// <summary> /// 指定した文字列内の指定した文字列を別の文字列に置換する。 /// </summary> /// <param name="input">置換する文字列のある文字列。</param> /// <param name="oldValue">検索文字列。</param> /// <param name="newValue">置換文字列。</param> /// <param name="count">置換する回数。負の数が指定されたときは、すべて置換する。</param> /// <param name="compInfo">文字列の検索に使用するCompareInfo。</param> /// <param name="compOptions">文字列の検索に使用するCompareOptions。</param> /// <returns>置換された結果の文字列。</returns> private static string StringReplace( string input, string oldValue, string newValue, int count, System.Globalization.CompareInfo compInfo, System.Globalization.CompareOptions compOptions) { if (input == null || input.Length == 0 || oldValue == null || oldValue.Length == 0 || count == 0) { return(input); } if (compInfo == null) { compInfo = System.Globalization.CultureInfo.InvariantCulture.CompareInfo; compOptions = System.Globalization.CompareOptions.Ordinal; } int inputLen = input.Length; int oldValueLen = oldValue.Length; System.Text.StringBuilder buf = new System.Text.StringBuilder(inputLen); int currentPoint = 0; int foundPoint = -1; int currentCount = 0; do { //文字列を検索する foundPoint = compInfo.IndexOf(input, oldValue, currentPoint, compOptions); if (foundPoint < 0) { buf.Append(input.Substring(currentPoint)); break; } //見つかった文字列を新しい文字列に換える buf.Append(input.Substring(currentPoint, foundPoint - currentPoint)); buf.Append(newValue); //次の検索開始位置を取得 currentPoint = foundPoint + oldValueLen; //指定回数置換したか調べる currentCount++; if (currentCount == count) { buf.Append(input.Substring(currentPoint)); break; } }while (currentPoint < inputLen); return(buf.ToString()); }
public static int Compare(StringSection a, StringSection b, bool ignoreCase, System.Globalization.CultureInfo culture, System.Globalization.CompareOptions options) { var result = string.Compare(a.baseString, a.start, b.baseString, b.start, Math.Min(a.length, b.length), culture, options); // If the two strings are different lengths, they are not equal. The longer string will be considered greater. if (result == 0 && a.length != b.length) { return(a.length > b.length ? 1 : -1); } return(result); }
public virtual int LastIndexOf(string source, char value, System.Globalization.CompareOptions options) { throw null; }
public virtual int Compare(string string1, string string2, System.Globalization.CompareOptions options) { throw null; }
public WordLocationTextExtractionStrategy(String textToSearchFor, System.Globalization.CompareOptions compareOptions = System.Globalization.CompareOptions.None) { this.TextToSearchFor = textToSearchFor; this.CompareOptions = compareOptions; }
public static System.StringComparer GetStringComparer(this System.Globalization.CompareInfo compareInfo, System.Globalization.CompareOptions options) { return(default(System.StringComparer)); }
/// <inheritdoc cref="System.String.Compare(System.String, System.Int32, System.String, System.Int32, System.Int32, System.Globalization.CultureInfo, System.Globalization.CompareOptions)" /> public static System.Int32 Compare(this System.String strA, System.Int32 indexA, System.String strB, System.Int32 indexB, System.Int32 length, System.Globalization.CultureInfo culture, System.Globalization.CompareOptions options) { return(System.String.Compare(strA, indexA, strB, indexB, length, culture, options)); }
public static int Compare(string strA, string strB, System.Globalization.CultureInfo culture, System.Globalization.CompareOptions options) => culture.CompareInfo.Compare(strA, strB, options);
public virtual int GetHashCode(string source, System.Globalization.CompareOptions options) { throw null; }
static int internal_index(System.Globalization.CompareInfo _this, string source, int sIndex, int count, char value, System.Globalization.CompareOptions options, bool first) { // if first == true find first incidence, else find last if (first) { for (int i = sIndex; i < (sIndex + count); i++) { if (source[i] == value) { return(i); } } } else { for (int i = (sIndex + count - 1); i >= sIndex; i--) { if (source[i] == value) { return(i); } } } return(-1); }
static int internal_index(System.Globalization.CompareInfo _this, string source, int sIndex, int count, string value, System.Globalization.CompareOptions options, bool first) { // if first == true find first incidence, else find last if (first) { for (int i = sIndex; i < (sIndex + count); i++) { bool found = true; for (int j = 0; j < value.Length; j++) { if (source[j + i] != value[j]) { found = false; break; } } if (found) { return(i); } } } else { for (int i = (sIndex + count - 1); i >= sIndex; i--) { bool found = true; for (int j = 0; j < value.Length; j++) { if (source[j + i] != value[j]) { found = false; break; } } if (found) { return(i); } } } return(-1); }
public virtual int LastIndexOf(string source, char value, System.Globalization.CompareOptions options) { return(default(int)); }
public virtual int LastIndexOf(string source, string value, int startIndex, int count, System.Globalization.CompareOptions options) { return(default(int)); }
public static int Compare(string strA, int indexA, string strB, int indexB, int length, system.globalization.CultureInfo culture, System.Globalization.CompareOptions options) => Compare(strA, indexA, strB, indexB, length, culture.CompareInfo, options);
static int CompareInfo_internal_compare(System.Globalization.CompareInfo ci, string str1, int offset1, int length1, string str2, int offset2, int length2, System.Globalization.CompareOptions options) { /* Based off the mono implementation */ int length = length1; if (length2 > length) { length = length2; } if ((offset1 + length) > str1.Length) { throw new Exception("Trying to compare more characters than exist in str1"); } if ((offset2 + length) > str2.Length) { throw new Exception("Trying to compare more characters than exist in str2"); } for (int i = 0; i < length; i++) { int cc = compare_char(str1[offset1 + i], str2[offset2 + i], options); if (cc != 0) { return(cc); } } return(0); }
public static int Compare(string strA, string strB, System.Globalization.CultureInfo culture, System.Globalization.CompareOptions options) { Contract.Requires(culture.CompareInfo != null); return(default(int)); }
public static System.StringComparer GetStringComparer(this System.Globalization.CompareInfo compareInfo, System.Globalization.CompareOptions options) { throw null; }
public virtual int Compare(string string1, int offset1, int length1, string string2, int offset2, int length2, System.Globalization.CompareOptions options) { return(default(int)); }
public virtual System.Globalization.SortKey GetSortKey(string source, System.Globalization.CompareOptions options) { throw new NotImplementedException(); }
public virtual int Compare(string string1, string string2, System.Globalization.CompareOptions options) { return(default(int)); }
public virtual int Compare(string string1, int offset1, int length1, string string2, int offset2, int length2, System.Globalization.CompareOptions options) { throw null; }
public virtual int GetHashCode(string source, System.Globalization.CompareOptions options) { return(default(int)); }
public virtual bool IsSuffix(string source, string suffix, System.Globalization.CompareOptions options) { throw null; }
public virtual bool IsSuffix(string source, string suffix, System.Globalization.CompareOptions options) { return(default(bool)); }
public virtual int LastIndexOf(string source, string value, int startIndex, int count, System.Globalization.CompareOptions options) { throw null; }
public TextAndLocationExtractionStrategy(System.Globalization.CompareOptions compareOptions = System.Globalization.CompareOptions.None) { CompareOptions = compareOptions; TextsWithLocations = new List <TextWithLocation>(); }