有个很少的C++源码急着需要翻译成其它源码,版主、高手请进。 Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiNetwork/html/delphi_20061121222148287.html
下面的源码是用来判断数据流的编码的,由一个叫jiangsheng的朋友提供,在此先谢谢他。
但是我不会用C++,现在急着需要用这个源码,请大虾们帮个忙,帮个忙把下面的源码翻译成vb\delphi或net的,或者做个DLL给我,最好是翻译成VB.NET的,小弟不胜感激,在此先谢谢了。Mail:237019683@qq.com
static HRESULT DetectCodePage(
IStreamPtr spStream,
std::vector<DWORD>& dwCodePages,
DWORD dwFlag = MLDETECTCP_8BIT,
DWORD dwPrefWinCodePage = 0)
{
HRESULT hr = S_OK;
const int N = 32;
INT nScores = N;
DetectEncodingInfo info[N];
hr = DetectCodepageInIStream(
dwFlag,
dwPrefWinCodePage,
spStream,
info,
&nScores);
if (FAILED(hr))
{
return hr;
}
for (int i = 0; i < nScores; i++)
{
dwCodePages.push_back(info[i].nCodePage);
}
return S_OK;
}
// IE5.0 or lator
static HRESULT DetectCodepageInIStream(
DWORD dwFlag,
DWORD dwPrefWinCodePage,
IStream *pstmIn,
DetectEncodingInfo *lpEncoding,
INT *pnScores)
{
HRESULT hr = S_OK;
try
{
IMultiLanguage2Ptr spMultiLanguage2 = GetMultiLanguage();
if (spMultiLanguage2 == NULL)
{
return E_FAIL;
}
这个是调用浏览器的spMultiLanguage2接口的一个方法DetectCodepageInIStream
hr = spMultiLanguage2->DetectCodepageInIStream(
dwFlag,
dwPrefWinCodePage,
pstmIn,
lpEncoding,
pnScores);
if (FAILED(hr))
{
return hr;
}
}
catch (...)
{
return E_FAIL;
}
return S_OK;
}
static IMultiLanguagePtr GetMultiLanguage()
{
HRESULT hr = S_OK;
IMultiLanguagePtr spMultiLanguage;
hr = spMultiLanguage.CreateInstance(__uuidof(CMultiLanguage));
if (FAILED(hr))
{
return NULL;
}
return spMultiLanguage;
}