nsCAutoString spec = NS_ConvertUCS2toUTF8(szTarget);
NS_ConvertUTF16toUTF8 spec(szTarget);
    virtual HRESULT STDMETHODCALLTYPE Navigate(         /* [in] */ DWORD grfHLNF,        /* [unique][in] */ LPBC pbc,        /* [unique][in] */ IBindStatusCallback *pibsc,        /* [unique][in] */ IHlink *pihlNavigate)    {        if (!pihlNavigate) return E_INVALIDARG;        // TODO check grfHLNF for type of link        LPWSTR szTarget = NULL;        LPWSTR szLocation = NULL;        LPWSTR szTargetFrame = NULL;        HRESULT hr;        hr = pihlNavigate->GetStringReference(HLINKGETREF_DEFAULT, &szTarget, &szLocation);        hr = pihlNavigate->GetTargetFrameName(&szTargetFrame);        if (szTarget && szTarget[0] != WCHAR('\0'))        {            nsCAutoString spec = NS_ConvertUCS2toUTF8(szTarget);            nsCOMPtr<nsIURI> uri;            nsresult rv = NS_NewURI(getter_AddRefs(uri), spec);            if (NS_SUCCEEDED(rv) && uri)            {                nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mDOMWindow);                if (webNav)                {                    nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(webNav);                    if (lh)                    {                        nsCOMPtr<nsPIDOMWindow> window =                            do_GetInterface(mDOMWindow);                        nsAutoPopupStatePusher popupStatePusher(window,                                                                openAllowed);                        lh->OnLinkClick(nsnull, eLinkVerb_Replace,                            uri, szTargetFrame ? szTargetFrame : mUseTarget);                    }                }                hr = S_OK;            }            else            {                hr = E_FAIL;            }        }        else        {            hr = E_FAIL;        }        if (szTarget)            CoTaskMemFree(szTarget);        if (szLocation)            CoTaskMemFree(szLocation);        if (szTargetFrame)            CoTaskMemFree(szTargetFrame);        if (mUseTarget)        {            SysFreeString(mUseTarget);            mUseTarget = NULL;        }        return hr;    }