diff options
Diffstat (limited to 'win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs')
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs index bd58ec6a0..c270860d0 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/InteropUtilities.cs @@ -13,7 +13,7 @@ namespace HandBrake.Interop using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
-
+ using System.Text;
using HandBrake.Interop.HbLib;
using Model.Encoding;
@@ -34,6 +34,30 @@ namespace HandBrake.Interop }
/// <summary>
+ /// Reads the given native UTF-8 string.
+ /// </summary>
+ /// <param name="stringPtr">The pointer to the string.</param>
+ /// <returns>The resulting string.</returns>
+ public static string ReadUtf8Ptr(IntPtr stringPtr)
+ {
+ var data = new List<byte>();
+ var ptr = stringPtr;
+ var offset = 0;
+ while (true)
+ {
+ byte ch = Marshal.ReadByte(ptr, offset++);
+ if (ch == 0)
+ {
+ break;
+ }
+
+ data.Add(ch);
+ }
+
+ return Encoding.UTF8.GetString(data.ToArray());
+ }
+
+ /// <summary>
/// Converts the given native HandBrake list to a managed list.
/// </summary>
/// <typeparam name="T">The type of structure in the list.</typeparam>
|