diff options
author | sr55 <[email protected]> | 2014-09-14 15:48:45 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-09-14 15:48:45 +0000 |
commit | 4dda09df6d7d337e04f816c9add2ca75ee169c18 (patch) | |
tree | 7d6982a98fc9b30aad1c1022f994c11da761ae48 /win | |
parent | 6d4c8fc2de12bb749c079ba1c6544b995ca9cc93 (diff) |
WinGui: Currently hb_title_s.path is directly marshalled as string. But this isn't good because path is UTF-8 encoded C string, and fails with non-ASCII characters. To fix this, treating path as raw UTF-8 byte array and converting to string in ConvertTitle() method should work. Patch Submitted by Taihei, review 760
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6404 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs | 35 | ||||
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs | 16 |
2 files changed, 22 insertions, 29 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index b08facbd2..6c4e26ede 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -829,20 +829,13 @@ namespace HandBrake.Interop IntPtr titleSetPtr = HBFunctions.hb_get_title_set(this.hbHandle);
hb_title_set_s titleSet = InteropUtilities.ToStructureFromPtr<hb_title_set_s>(titleSetPtr);
this.originalTitles = titleSet.list_title.ToListFromHandBrakeList<hb_title_s>();
-
- foreach (hb_title_s title in this.originalTitles)
- {
- var newTitle = this.ConvertTitle(title);
-
- // Convert the Path to UTF-8.
- byte[] bytes = Encoding.Default.GetBytes(title.path);
- string utf8Str = Encoding.UTF8.GetString(bytes);
- newTitle.Path = utf8Str;
-
- this.titles.Add(newTitle);
- }
-
- if (this.originalTitles.Count > 0)
+ + foreach (hb_title_s title in this.originalTitles) + { + this.titles.Add(this.ConvertTitle(title)); + } + + if (this.originalTitles.Count > 0) {
this.featureTitle = titleSet.feature;
}
@@ -1881,13 +1874,13 @@ namespace HandBrake.Interop AspectRatio = title.aspect,
AngleCount = title.angle_count,
VideoCodecName = title.video_codec_name,
- Framerate = ((double)title.rate) / title.rate_base,
- FramerateNumerator = title.rate,
- FramerateDenominator = title.rate_base,
- Path = title.path
- };
-
- switch (title.type)
+ Framerate = ((double)title.rate) / title.rate_base, + FramerateNumerator = title.rate, + FramerateDenominator = title.rate_base, + Path = Encoding.UTF8.GetString(title.path).TrimEnd('\0') + }; + + switch (title.type) {
case hb_title_type_anon.HB_STREAM_TYPE:
newTitle.InputType = InputType.Stream;
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs index d9a845081..a3152c4be 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/hb_title_s.cs @@ -16,14 +16,14 @@ namespace HandBrake.Interop.HbLib /// Anonymous_990d28ea_6cf3_4fbc_8143_4df9513e9550
public hb_title_type_anon type;
- public uint reg_desc;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
- public string path;
-
- /// char[1024]
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
+ public uint reg_desc; + + /// char[1024] + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)] + public byte[] path; + + /// char[1024] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] public string name;
/// int
|