Пример #1
0
 public extern virtual void IMultiLanguage3_DetectInputCodepage([In] uint dwFlag, [In] uint dwPrefWinCodePage, [In] ref sbyte pSrcStr, [In] [Out] ref int pcSrcSize, out tagDetectEncodingInfo lpEncoding, [In] [Out] ref int pnScores);
Пример #2
0
        private Encoding[] DetectEncodings(byte[] bytes, int scores)
        {
            sbyte[] sbytes = (sbyte[])(object)bytes;
            int length = sbytes.Length;

            IMultiLanguage2 multiLanguage = new CMultiLanguageClass();
            tagDetectEncodingInfo[] detectEncodingInfo = new tagDetectEncodingInfo[scores];
            Encoding[] detectedEncodings = new Encoding[scores];

            try {
                multiLanguage.DetectInputCodepage((uint)(tagMLDETECTCP.MLDETECTCP_NONE), 0U, ref sbytes[0], ref length, out detectEncodingInfo[0], ref scores);
            } catch (Exception exception) {
                Debug.WriteLine($"{exception.GetType()} - {exception.Message}");
            } finally {
                Marshal.ReleaseComObject(multiLanguage);
            }

            try {
                for (int i = 0; i < scores; i++) {
                    detectedEncodings[i] = Encoding.GetEncoding((int)detectEncodingInfo[i].nCodePage);
                }
                return detectedEncodings;
            } catch (Exception exception) {
                Debug.WriteLine($"{exception.GetType()} - {exception.Message}");
                return null;
            }
        }
Пример #3
0
 public extern virtual void IMultiLanguage3_DetectCodepageInIStream([In] uint dwFlag, [In] uint dwPrefWinCodePage, [MarshalAs(UnmanagedType.Interface)] [In] IStream pstmIn, out tagDetectEncodingInfo lpEncoding, [In] [Out] ref int pnScores);