diff --git a/src/capi.cs b/src/capi.cs
index 18871c07d7e68e2cc1da70d1832e61ac972a6ede..ec8c346d7a953aa53cf38e32264ae4311f939449 100644
--- a/src/capi.cs
+++ b/src/capi.cs
@@ -27,52 +27,52 @@ internal class Capi
 {
 	public delegate void resultDlg(IntPtr result, ref CNetwork network, IntPtr data);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, EntryPoint = "kiss_free", CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, EntryPoint = "kiss_free", CallingConvention=CallingConvention.StdCall)]
 	public static extern void free(IntPtr ptr);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern IntPtr kiss_create_range(float start, float end, UIntPtr length, byte log);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern void kiss_resample_spectra(float[] in_re, float[] in_im, UIntPtr input_length, ref IntPtr ret_ptr_real, ref IntPtr ret_ptr_imag, UIntPtr output_length);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern void kiss_normalize_spectra(float[] in_re, float[] in_im, UIntPtr input_length);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern IntPtr kiss_absgrad(float[] in_re, float[] in_im, float[] omegas, UIntPtr input_length, UIntPtr index);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern float kiss_grad(float[] data, float[] omegas, UIntPtr input_length, UIntPtr index);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern float kiss_median(float[] data, UIntPtr input_length);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern byte kiss_reduce_spectra(float[] in_re, float[] in_im, float[] omegas, UIntPtr input_length, float thresh_factor,
 												  byte use_second_deriv, ref IntPtr out_re, ref IntPtr out_im, ref UIntPtr output_length);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 
 	public static extern byte kiss_filter_spectra(float[] in_re, float[] in_im, float[] omegas, UIntPtr input_length,
 												  ref IntPtr out_re, ref IntPtr out_im, UIntPtr output_length);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern byte kiss_load_network_prealloc(ref CNetwork net, string path, resultDlg callback, byte verbose);
 
-	[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("libc", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern void puts(string path);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern void kiss_free_network_prealloc(ref CNetwork net);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern byte kiss_async_run_inference(ref CNetwork net, [Out] float[] inputs, IntPtr data);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern byte kiss_async_run_inference_complex(ref CNetwork net, [Out] float[] real, [Out] float[] imag, IntPtr data);
 
-	[DllImport("kissinference", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
+	[DllImport("kissinference", CharSet = CharSet.Unicode, SetLastError = true, CallingConvention=CallingConvention.StdCall)]
 	public static extern IntPtr kiss_get_strerror(ref CNetwork net);
 
 	public static string[] IntPtrToUtf8Array(IntPtr array)
@@ -107,6 +107,7 @@ internal class Capi
 				break;
 
 			bytes.Add(b);
+			idx++;
 		}
 
 		return System.Text.Encoding.UTF8.GetString(bytes.ToArray());