public static unsafe String CallBackTranslateString(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 *= 4096; } char *outBuffer = (char *)Marshal.AllocHGlobal(outputLength); int r_outputLength = outputLength; int mode = 8; //default value mode = (int)translationMode; int code = LouisWrapper.lou_backTranslateString(inputTables, source, ref inputLength, outBuffer, ref r_outputLength, null, null, mode); string uniString = Marshal.PtrToStringUni((IntPtr)outBuffer); Marshal.FreeHGlobal((IntPtr)outBuffer); uniString = uniString.Substring(0, r_outputLength); return(uniString); } catch (Exception e) { //Console.WriteLine(e.Message); //return null; throw e; } }