runtime: Got Illegal character error when the file name is encoded in GBK
Hi All,
We just encountered an issue that the enumeration function reports error of illegal character when there’s GBK Chinese character in the directory. We found this issue on RedHat 7.3 with $LANG and $LC_ALL set to “zh_CN.GBK”. It works well with Chines character with UTF-8 encoding. The issue can be reproduced by following code:
using System;
using System.IO;
namespace netcoretest
{
class Program
{
static void Main(string[] args)
{
foreach (var fileItem in Directory.EnumerateFileSystemEntries(".", "*", SearchOption.TopDirectoryOnly))
{
Console.WriteLine(fileItem);
}
}
}
}
It reports an error as following:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
Parameter name: path
at System.IO.PathInternal.CheckInvalidPathChars(String path)
at System.IO.Path.Combine(String path1, String path2)
at System.IO.UnixFileSystem.FileSystemEnumerable`1.<Enumerate>d__11.MoveNext()
at netcoretest.Program.Main(String[] args) in /home/xtest/netcoretest/Program.cs:line 10
Aborted (core dumped)
GBK is an encoding standard defined by China. Does .Net Core framework have plan to support other encoding besides Unicode? If so, could you share your schedule?
Thanks Emma
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (23 by maintainers)
Some more info on the OpenJDK implementation (credits: Andrew Haley)