Skip to content

Commit

Permalink
Merge pull request #1171 from maiko3tattun/240609_FixWavtool
Browse files Browse the repository at this point in the history
Fix wavtool not working when full path contains 2 byte characters
  • Loading branch information
stakira authored Jun 9, 2024
2 parents f9324c7 + 0c529c4 commit fd8c501
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions OpenUtau.Core/Classic/ExeWavtool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class ExeWavtool : IWavtool {
readonly StringBuilder sb = new StringBuilder();
readonly string filePath;
readonly string name;
private Encoding osEncoding;

public ExeWavtool(string filePath, string basePath) {
this.filePath = filePath;
name = Path.GetRelativePath(basePath, filePath);
osEncoding = OS.IsWindows() ? Encoding.GetEncoding(0) : Encoding.UTF8;
}

public float[] Concatenate(List<ResamplerItem> resamplerItems, string tempPath, CancellationTokenSource cancellation) {
Expand All @@ -39,7 +41,7 @@ public float[] Concatenate(List<ResamplerItem> resamplerItems, string tempPath,
string batPath = Path.Combine(PathManager.Inst.CachePath, "temp.bat");
lock (tempBatLock) {
using (var stream = File.Open(batPath, FileMode.Create)) {
using (var writer = new StreamWriter(stream, new UTF8Encoding(false))) {
using (var writer = new StreamWriter(stream, osEncoding)) {
WriteSetUp(writer, resamplerItems, tempPath);
for (var i = 0; i < resamplerItems.Count; i++) {
WriteItem(writer, resamplerItems[i], i, resamplerItems.Count);
Expand All @@ -62,7 +64,7 @@ void PrepareHelper() {
lock (Renderers.GetCacheLock(tempHelper)) {
if (!File.Exists(tempHelper)) {
using (var stream = File.Open(tempHelper, FileMode.Create)) {
using (var writer = new StreamWriter(stream, new UTF8Encoding(false))) {
using (var writer = new StreamWriter(stream, osEncoding)) {
WriteHelper(writer);
}
}
Expand Down

0 comments on commit fd8c501

Please sign in to comment.