-extern long wxCharsetToCodepage(const wxChar *name)
-{
- // first get the font encoding for this charset
- if ( !name )
- return -1;
-
- wxFontEncoding enc = wxTheFontMapper->CharsetToEncoding(name, FALSE);
- if ( enc == wxFONTENCODING_SYSTEM )
- return -1;
-
- // the use the helper function
- return wxEncodingToCodepage(enc);
-}
-
-#endif // wxUSE_FONTMAP
-
-#endif // wxUSE_GUI
-
-// include old wxCharsetToCodepage() by OK if needed
-#if !wxUSE_GUI || !wxUSE_FONTMAP
-
-#include "wx/msw/registry.h"
-
-// this should work if Internet Exploiter is installed
-extern long wxCharsetToCodepage(const wxChar *name)
-{
- if (!name)
- return GetACP();
-
- long CP=-1;
-
- wxString cn(name);
- do {
- wxString path(wxT("MIME\\Database\\Charset\\"));
- path += cn;
- wxRegKey key(wxRegKey::HKCR, path);
-
- if (!key.Exists()) break;
-
- // two cases: either there's an AliasForCharset string,
- // or there are Codepage and InternetEncoding dwords.
- // The InternetEncoding gives us the actual encoding,
- // the Codepage just says which Windows character set to
- // use when displaying the data.
- if (key.HasValue(wxT("InternetEncoding")) &&
- key.QueryValue(wxT("InternetEncoding"), &CP)) break;
-
- // no encoding, see if it's an alias
- if (!key.HasValue(wxT("AliasForCharset")) ||
- !key.QueryValue(wxT("AliasForCharset"), cn)) break;
- } while (1);
-
- return CP;