You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
byte[]byteArray=File.ReadAllBytes(filePath);// count every second byte array if its zero.intzeroBytesCount=0;for(inti=1;i<byteArray.Length;i+=2){if(byteArray[i]==0){zeroBytesCount++;}}Encodingencoding=Encoding.UTF8;// if count is bigger or equal to 40% of the byte array, it most likely UTF16if(zeroBytesCount>=byteArray.Length*0.4){encoding=Encoding.Unicode;}else{DetectionDetaildetector=CharsetDetector.DetectFromBytes(byteArray).Detected;encoding=detector.Encoding;}
The text was updated successfully, but these errors were encountered:
UTF16_Test.csv
For the provided file the encoding is not detected as
UTF16 LE
even though it is.As workaround i am now using this code
The text was updated successfully, but these errors were encountered: