/// <summary> /// Convert char* to correctly encoded string, clean up of received char* is optional /// </summary> /// <param name="input">Char* to convert</param> /// <param name="release">Clean up char* or not (don't do that if it is still should be used somewhere)</param> /// <returns>Converted string</returns> private static unsafe string getString(char *input, bool release) { string returnString = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.Unicode.GetBytes(new string(input))); if (returnString.Contains("\0")) { returnString = returnString.Substring(0, returnString.IndexOf('\0')); } if (release) { UnmanagedImport.tdReleaseString(input); } GC.Collect(); return(returnString); }