How to use it with powershell/core script
dahikino opened this issue · comments
Hello,
I try to load the dll as module but i can't find the way to use the class CharsetDetector, with issue result :
New-Object: A constructor was not found. Cannot find an appropriate constructor for type UtfUnknown.CharsetDetector.
Have you any idea how to do it ?
Best regards
Hi, could you please provide an example?
Finally i found how to do it in a file script:
Add-Type -Path .\UtfUnknown.dll
[UtfUnknown.CharsetDetector]::DetectFromFile($filePath)
This is a example for the method DetectFromFile.
If you want only the code charset as result :
Add-Type -Path .\UtfUnknown.dll
[UtfUnknown.CharsetDetector]::DetectFromFile($filePath).detected.EncodingName.ToString()
Refering in the xml to other methods, replace DetectFromFile method by the one you need !
More generally, the syntax using .Net library in Powershell is :
[namespace.classname]::method
Thanks for sharing!
Closing as self answered. Thanks again :)