diff options
author | sr55 <[email protected]> | 2015-01-09 19:30:30 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-09 19:30:30 +0000 |
commit | 6301bd5b63dd8c7e095331d22fe196210c79f316 (patch) | |
tree | 96f266f9e89b3eb4d917324557c7be55d25d88b7 | |
parent | c3b7d0bd1b901c17a345123b7c640eabf69f6a90 (diff) |
WinGui: Fix an issue with non-ASCII characters in the new JSON Scan API. Thanks to Taihei for pointing out the solution.
https://reviews.handbrake.fr/r/778
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6701 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index 0ed007e53..7a7aaab5c 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -605,17 +605,18 @@ namespace HandBrake.Interop this.titles = new List<Title>();
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);
- string scanJson = Marshal.PtrToStringAnsi(jsonMsg);
+ // Convert UTF-8 encoded jsonMsg to string
+ int length = 0;
+ while (Marshal.ReadByte(jsonMsg, length) != 0) length++; // find 0 termination
+ byte[] buffer = new byte[length];
+ Marshal.Copy(jsonMsg, buffer, 0, buffer.Length);
+ string scanJson = Encoding.UTF8.GetString(buffer);
+
JsonScanObject scanObject = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
lastScan = scanObject;
foreach (Title title in ScanFactory.CreateTitleSet(scanObject))
{
- // Convert the Path to UTF-8.
- byte[] bytes = Encoding.Default.GetBytes(title.Path);
- string utf8Str = Encoding.UTF8.GetString(bytes);
- title.Path = utf8Str;
-
// Set the Main Title.
this.featureTitle = title.IsMainFeature ? title.TitleNumber : 0;
|