Fix issues when loadmodel from model file which contains Unicode #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This issue happens when there are Unicode characters exist in model file name. To test it I simply modified the nuget test project, updates the model file name from "bert_base_tok.bin" to "bert_base_tok★.bin". Then when we run the test we got the exception:
"
Model File Name is: ./bin/Debug/net6.0/bert_base_tokΓÿà.bin
Unhandled exception. System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at BlingFire.BlingFireUtils.LoadModel(Byte[] modelName)
"
setlocale(LC_ALL, ".UTF8") fixes this issue. I've tested it on x64-windows ,arm64-windows, osx-arm64. will do more testes on other platforms.