Closed alexey-lysiuk closed 1 year ago
Is that @try{} @catch() {}
a requirement of the old code?
I cannot say for such old versions of macOS, but actual versions need it as exception is thrown when conversion fails.
I guess [clipboardString cString]
implies an actual conversion to ASCII?
And, no exception thrown for the new [clipboardString cStringUsingEncoding: NSASCIIStringEncoding]
?
Yes, "new" path returns NULL
if conversion fails.
OK then.
For old targets: Instead of try/catch, would it be safe to do the following?
if (! [clipboardString canBeConvertedToEncoding:NSASCIIStringEncoding])
return NULL;
srcdata = [clipboardString cString];
Replaced exception handling with check for possibility of conversion to ASCII.
The patch is in, thank you! And I also applied it to uhexen2 project.
Attempt to paste text that contains non-ASCII characters leads to a crash Depending on code path, it's a copy from null pointer or an unhandled exception