public static unsafe String CallTranslateString(String source, String translationTables, int translationMode) { try { if (string.IsNullOrWhiteSpace(source)) { return(null); } string inputTables = ""; if (translationTables.Length > 1) { foreach (string s in translationTables.Split(',')) { inputTables += @"tables\" + s + ","; } inputTables = inputTables.Substring(0, inputTables.Length - 1); } else { inputTables = @"tables\" + translationTables; } int inputLength = source.Length; int outputLength = 1; while (outputLength < source.Length) { outputLength *= 40960; } char *outBuffer = (char *)Marshal.AllocHGlobal(outputLength); int r_outputLength = outputLength; inputString = source; int mode = 8; //default value mode = (int)translationMode; int code = LouisWrapper.lou_translateString(inputTables, inputString, ref inputLength, outBuffer, ref r_outputLength, null, null, mode); if (code == 1) { string uniString = Marshal.PtrToStringAuto((IntPtr)outBuffer); Marshal.FreeHGlobal((IntPtr)outBuffer); if (uniString.Length > r_outputLength) { uniString = uniString.Substring(0, r_outputLength); } return(uniString); } else { return(null); } } catch (Exception e) { throw e; //return null; } }
public static unsafe bool FreeLibrary() { try { LouisWrapper.lou_free(); return(true); } catch (Exception e) { return(false); } }
public static unsafe string GetVersion() { return("Library version: " + Marshal.PtrToStringAnsi((IntPtr)LouisWrapper.lou_version())); }
public void Dispose() { LouisWrapper.FreeLibrary(); Environment.CurrentDirectory = holder; holder = null; }
public string GetLibraryVersion() { return(LouisWrapper.GetVersion()); }
public String BackTranslateString(String source, String translationTables, int mode) { return(LouisWrapper.CallBackTranslateString(source, translationTables, mode)); }