-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Csound::Compile() won't work if non-English characters in path.. #632
Comments
I tried a similar test on OSX
and it passed. |
I think the problem is that the string encoding in the source file does not match the encoding used at runtime, thus "special" characters get garbled. @rorywalsh, does the problem persist if you pass the filename via a command line argument to your test program? Also, you can test changing the file encoding to different things (try with utf-8, notepad++ has a |
Thanks Fiipe, passing the filename from the command line does work but encoding my files as utf8 doesn't make any difference. Any other ideas? |
Csound seems to replace the Á with ├ü on Windows? There's hardly a compiler setting I'm overlooking or something?
[edit] Just found this link, https://sourceforge.net/p/mingw-w64/wiki2/Unicode%20apps/, perhaps that's the key. I'll try it out and post back when I get the chance. |
Rory, did you try other encoding options? Unfortunately, because c strings have 8bit characters, your sources need to
|
I did Felipe, but none seem to work. I'll keep digging. |
It seems the fopen() on windows at least will not return a valid FILE pointer if non-ascii chars are in the file path. The solution is to use _wfopen() which I think is Windows only. Using _wfopen() instead of fopen in the following code fixes the issue. https://github.com/csound/csound/blob/develop/Engine/envvar.c#L1011-L1019 But it's obviously Windows only. Would the devs mind implementing this with some if-def blocks? |
that could be done for some files, but I wonder if libsndfile would do this too? Can you try and see |
If arguents te sane or near same I would prefer a macro so easy to use all On Fri, 22 Apr 2016, Rory Walsh wrote:
|
@vlazzarini : diskin2 fails with wide characters. In fact, it seems that any strings with wide chars chars on Windows will not be read properly. Include files that use non-ascii paths also return a not found error. @jpffitch in those lines I quoted, fullName needs to be a wchar_t_, while params needs to be cast as a wchar_t_. Something like this does it(I say like this because I'm not at the machine I tested it on, but that's more or less what I did):
|
not sure if we call fopen or we let libsndfile do it for us. If it is the second case, then you'll need to ask Erik. |
Considering Csound can't handle non-ascii characters the diskin issue is not as big one for me. (although it may well confuse some users). Not being able to compile a file with the API that has non-ascii characters in its path concerns me more. |
Ok, I looked and we use libsndfile sf_open etc functions to open soundfile. So that's that. As for standard files, we use fopen, which could be replaced on windows for a more suitable function. It's in envvar.c . You could possibly try it and see if it does anything, then we could look at adding to the sources. |
The solution is the same as the one I posted a few hours ago, we should use _wfopen(). |
That may be, but it would be good if you could try and let us know. We're linux-osx people here. Victor Lazzarini
|
I have tried it. I tested it on Windows just before I posted the solution. That's why I refer to it as a "solution" ;) But I'd still rather leave it to you guys to implement it the way you see fit. |
I see. But we need a Windows developer to implement it all, so we are not doing it blindly. |
I think this is sorted now. I've updated my original code snippet with working code. I've tested with simple command line API programs and I've also tested it with Cabbage. I left |
When you say sorted does it need changes to csound sources? |
Yes, if you wouldn't mind. The code is posted above. On 24 April 2016 at 15:43, John ffitch notifications@github.com wrote:
|
In git; did I get it right? |
There seems to be a stray bracket there. I've emailed you the fixed version. On 24 April 2016 at 17:31, John ffitch notifications@github.com wrote:
|
I also found and fixed this. Regards, Michael Gogins On Sun, Apr 24, 2016 at 2:14 PM, Rory Walsh notifications@github.com
|
The code is a partial fix at best. There are other calls to fopen and open in envvar.c that are unmodified I still cannot see any extra brackets either |
I just ran into an issue with this latest change when using Microsoft's .NET framework. It seems that it doesn't appreciate the call to _wfopen() and produces a problem with msvcrt.dll. It's not easy to fix as there are no debug tools that can help. But reverting the code does make the issue go away. I'm not sure what's the best course of action here. The fix allows us to open files paths with non-English characters on Windows, but causes a problem for anyone using Csound with .NET. What would people think about a new compile method to deal with non-English paths? Would this be appropriate? Users could just call this instead of the normal csoundCompile() on Windows if they wanted it? Or has anyone any other suggestions? |
is it possible to detect at runtime that .net is being used? There are a number of calls to fopen in the sources. Which do you think should get the _wfopen treatment? |
I'm not sure. I wouldn't suggest any of them get the _wfopen() treatment if it means not being able to use Csound with .net. I don't know how best to proceed. |
Provide a "_w" variant. Regards, On Oct 10, 2016 9:52 AM, "Rory Walsh" notifications@github.com wrote:
|
I thought the problem was in .net Sent from TypeApp On 10 Oct 2016, 16:35, at 16:35, Michael Gogins notifications@github.com wrote:
|
Here's a quick run down of the issue. Csound won't open files that have On 10 October 2016 at 19:13, John ffitch notifications@github.com wrote:
|
I think this is a won't fix case. Can we have an #ifdef C# or something? |
More a cannot fix as Windows does not provide a working fopen. For now we should just keep this problem in mind |
Can we not use some kind of if/def as Victor suggested? On 24 October 2016 at 11:42, John ffitch notifications@github.com wrote:
|
This sounds like a reasonable solution. On 20 October 2016 at 21:08, vlazzarini notifications@github.com wrote:
|
Many of my students have non-English characters in their names. Their home directory, which is the base of all their document paths, therefore contains non English characters. When I use these paths with Csound::Compile() I get:
Below is a simple .cpp file you can test with it. Note that I've only tested this on Windows. I think it's working fine on other platforms. There is no problem when I use the offending path directly with the Csound command line.
The text was updated successfully, but these errors were encountered: