protected override void loadTestFunction() { if (testName == "TestWin_GetSortKey") { myTestFunction = new TestFunction(TestWin); } else if (testName == "TestICU_GetSortKey") { myTestFunction = new TestFunction(TestICU); } else { Console.Out.WriteLine("Unknown test name: {0}", testName); Environment.Exit(2); } if (testName.Contains("Win")) { wComp = new CultureInfo(wlocaleName, false).CompareInfo; } else { unsafe { fixed(byte *p = locale) { coll = ucol_open(p, ref status); status = (UErrorCode)0; } } } }
public static string DetectCharacterSetICU(byte[] buffer) { UErrorCode error = UErrorCode.U_ZERO_ERROR; IntPtr detector = ucsdet_open(ref error); if (error != UErrorCode.U_ZERO_ERROR) { throw new Win32Exception(error.ToString()); } try { ucsdet_setText(detector, ref buffer[0], buffer.Length, ref error); if (error != UErrorCode.U_ZERO_ERROR) { throw new Win32Exception(error.ToString()); } IntPtr match = ucsdet_detect(detector, ref error); if (error != UErrorCode.U_ZERO_ERROR) { throw new Win32Exception(error.ToString()); } IntPtr match_encoding = ucsdet_getName(match, ref error); if (error != UErrorCode.U_ZERO_ERROR) { throw new Win32Exception(error.ToString()); } return(Marshal.PtrToStringAnsi(match_encoding)); } finally { ucsdet_close(detector); } }
public unsafe static extern int unorm_normalize( char[] source, int sourceLength, UNormalizationMode mode, int options, char *result, int resultLength, ref UErrorCode status );
public void setLocale(icu.Locale locale) { UErrorCode status = U_ZERO_ERROR; mBreakIterator.reset(icu.BreakIterator.createLineInstance(locale, status)); // TODO: handle failure status if (mText != null) { mBreakIterator.setText(mUText, status); } mIteratorWasReset = true; }
public void setText(UInt16 data, int size) { mText = data; mTextSize = size; mIteratorWasReset = false; mLast = 0; mCurrent = 0; mScanOffset = 0; mInEmailOrUrl = false; UErrorCode status = U_ZERO_ERROR; //C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'reinterpret_cast' in C#: utext_openUChars(mUText, reinterpret_cast <const UChar>(data), size, status); mBreakIterator.setText(mUText, status); mBreakIterator.first(); }
private unsafe void conveterBox_SelectedIndexChanged(object sender, System.EventArgs e) { ComboBox box = (ComboBox)sender; byte * convNameBytes = ucnv_getAvailableName(box.SelectedIndex); UErrorCode errorCode = UErrorCode.U_ZERO_ERROR; aliasListBox.Items.Clear(); if (convNameBytes != null) { short aliasCount = ucnv_countAliases(convNameBytes, ref errorCode); for (short idx = 0; idx < aliasCount; idx++) { string convAlias = ToString(ucnv_getAlias(convNameBytes, idx, ref errorCode)); aliasListBox.Items.Add(convAlias); } } }
public BidiText(UInt16 buf, int start, int count, int bufSize, int bidiFlags) { //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mStart = start; this.mStart.CopyFrom(start); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mEnd = start + count; this.mEnd.CopyFrom(start + count); //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: this.mBufSize = bufSize; this.mBufSize.CopyFrom(bufSize); this.mBidi = null; this.mRunCount = 1; this.mIsRtl = (bidiFlags & GlobalMembers.kDirection_Mask) != 0; if (bidiFlags == kBidi_Force_LTR || bidiFlags == kBidi_Force_RTL) { // force single run. return; } mBidi = ubidi_open(); if (mBidi == null) { ALOGE("error creating bidi object"); return; } UErrorCode status = U_ZERO_ERROR; // Set callbacks to override bidi classes of new emoji ubidi_setClassCallback(mBidi, emojiBidiOverride, null, null, null, status); if (!U_SUCCESS(status)) { ALOGE("error setting bidi callback function, status = %d", status); return; } UBiDiLevel bidiReq = bidiFlags; if (bidiFlags == kBidi_Default_LTR) { bidiReq = UBIDI_DEFAULT_LTR; } else if (bidiFlags == kBidi_Default_RTL) { bidiReq = UBIDI_DEFAULT_RTL; } //C++ TO C# CONVERTER TODO TASK: There is no equivalent to 'reinterpret_cast' in C#: ubidi_setPara(mBidi, reinterpret_cast <const UChar>(buf), mBufSize, bidiReq, null, status); if (!U_SUCCESS(status)) { ALOGE("error calling ubidi_setPara, status = %d", status); return; } int paraDir = ubidi_getParaLevel(mBidi) & GlobalMembers.kDirection_Mask; uint rc = ubidi_countRuns(mBidi, status); if (!U_SUCCESS(status) || rc < 0) { ALOGW("error counting bidi runs, status = %d", status); } if (!U_SUCCESS(status) || rc <= 1) { mIsRtl = (paraDir == kBidi_RTL); return; } mRunCount = rc; }
private static extern IntPtr ucsdet_getName(IntPtr ucsd, ref UErrorCode status);
private static extern IntPtr ucsdet_detect(IntPtr ucsd, ref UErrorCode status);
private static extern void ucsdet_setText(IntPtr ucsd, ref byte textIn, int len, ref UErrorCode status);
private static extern IntPtr ucsdet_open(ref UErrorCode status);
public static extern unsafe byte *ucnv_getAlias(byte *alias, short n, ref UErrorCode pErrorCode);
public static extern unsafe short ucnv_countAliases(byte *alias, ref UErrorCode pErrorCode);
public unsafe static extern IntPtr ucol_open(byte *locale, ref UErrorCode status);