OSDN Git Service

Remove codepage.*
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 2 Jan 2017 08:50:55 +0000 (17:50 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 2 Jan 2017 08:50:55 +0000 (17:50 +0900)
21 files changed:
Src/Common/ExConverter.cpp
Src/Common/UniFile.cpp
Src/Common/UniFile.h
Src/Common/multiformatText.cpp
Src/Common/unicoder.h
Src/ConfigLog.cpp
Src/DirScan.cpp
Src/FileTextEncoding.cpp
Src/FilterList.cpp
Src/FilterList.h
Src/ImgMergeFrm.cpp
Src/Merge.vcxproj
Src/Merge.vcxproj.filters
Src/MergeDoc.cpp
Src/UniMarkdownFile.cpp
Src/codepage.cpp [deleted file]
Src/codepage.h [deleted file]
Src/codepage_detect.cpp
Testing/GoogleTest/UnitTests/UnitTests.vcxproj
Testing/GoogleTest/UnitTests/UnitTests.vcxproj.filters
Testing/GoogleTest/unicoder/unicoder_test.cpp

index 6a20e7c..23a9eb8 100644 (file)
@@ -12,7 +12,6 @@
 #define POCO_NO_UNWINDOWS 1
 #include <Poco/Mutex.h>
 #include "unicoder.h"
-#include "codepage.h"
 
 #if !defined(__IMultiLanguage2_INTERFACE_DEFINED__) && !defined(__GNUC__)
 #error "IMultiLanguage2 is not defined in mlang.h. Please install latest Platform SDK."
@@ -89,9 +88,9 @@ public:
        {
                bool bsucceeded;
 #ifdef POCO_ARCH_BIG_ENDIAN
-               if (srcCodepage == CP_UCS2BE)
+               if (srcCodepage == ucr::CP_UCS2BE)
 #else
-               if (srcCodepage == CP_UCS2LE)
+               if (srcCodepage == ucr::CP_UCS2LE)
 #endif
                {
                        size_t srcwchars = *srcbytes / sizeof(wchar_t);
@@ -144,7 +143,7 @@ public:
                UINT srcsize;
                HRESULT hr;
 
-               hr = m_pmlang->CreateConvertCharset(autodetectType, CP_UCS2LE, MLCONVCHARF_AUTODETECT, &pcc);
+               hr = m_pmlang->CreateConvertCharset(autodetectType, ucr::CP_UCS2LE, MLCONVCHARF_AUTODETECT, &pcc);
                if (FAILED(hr))
                        return defcodepage;
                srcsize = static_cast<UINT>(size);
@@ -161,20 +160,20 @@ public:
                                if (size < 2 || (data[0] != 0 && data[1] != 0))
                                {
                                        codepagestotry[0] = defcodepage;
-                                       codepagestotry[1] = CP_UTF8;
+                                       codepagestotry[1] = ucr::CP_UTF_8;
                                }
                        }
                        else
                        {
                                if (size < 2 || (data[0] != 0 && data[1] != 0))
-                                       codepagestotry[0] = CP_UTF8;
+                                       codepagestotry[0] = ucr::CP_UTF_8;
                        }
                        codepage = defcodepage;
                        int i;
                        for (i = 0; i < sizeof(codepagestotry)/sizeof(codepagestotry[0]) - 1; i++)
                        {
                                if (codepagestotry[i] == 0) break;
-                               pcc->Initialize(codepagestotry[i], CP_UCS2LE, 0);
+                               pcc->Initialize(codepagestotry[i], ucr::CP_UCS2LE, 0);
                                srcsize = static_cast<UINT>(size);
                                dstsize = static_cast<UINT>(size * sizeof(wchar_t));
                                SetLastError(0);
@@ -209,9 +208,9 @@ public:
                                if (lezerocount > 0 || bezerocount > 0)
                                {
                                        if ((lecrorlf == 0 && size < 512 || (lecrorlf > 0 && (size / lecrorlf > 1024))) && lezerocount > bezerocount)
-                                               codepage = CP_UCS2LE;
+                                               codepage = ucr::CP_UCS2LE;
                                        else if ((becrorlf == 0 && size < 512 || (becrorlf > 0 && (size / becrorlf > 1024))) && lezerocount < bezerocount)
-                                               codepage = CP_UCS2BE;
+                                               codepage = ucr::CP_UCS2BE;
                                }
                        }
                }
index ecee7fe..65da9f8 100644 (file)
@@ -328,19 +328,19 @@ bool UniMemFile::ReadBom()
        switch (m_unicoding)
        {
        case ucr::UCS2LE:
-               m_codepage = CP_UCS2LE;
+               m_codepage = ucr::CP_UCS2LE;
                m_charsize = 2;
                m_data = lpByte + 2;
                unicode = true;
                break;
        case ucr::UCS2BE:
-               m_codepage = CP_UCS2BE;
+               m_codepage = ucr::CP_UCS2BE;
                m_charsize = 2;
                m_data = lpByte + 2;
                unicode = true;
                break;
        case ucr::UTF8:
-               m_codepage = CP_UTF8;
+               m_codepage = ucr::CP_UTF_8;
                m_charsize = 1;
                if (bom)
                        m_data = lpByte + 3;
@@ -835,19 +835,19 @@ bool UniStdioFile::ReadBom()
        switch (m_unicoding)
        {
        case ucr::UCS2LE:
-               m_codepage = CP_UCS2LE;
+               m_codepage = ucr::CP_UCS2LE;
                m_charsize = 2;
                m_data = 2;
                unicode = true;
                break;
        case ucr::UCS2BE:
-               m_codepage = CP_UCS2BE;
+               m_codepage = ucr::CP_UCS2BE;
                m_charsize = 2;
                m_data = 2;
                unicode = true;
                break;
        case ucr::UTF8:
-               m_codepage = CP_UTF8;
+               m_codepage = ucr::CP_UTF_8;
                if (bom)
                        m_data = 3;
                else
index a667771..b41fce3 100644 (file)
@@ -92,15 +92,15 @@ public:
                m_codepage = codepage;
                switch (m_codepage)
                {
-               case CP_UCS2LE:
+               case ucr::CP_UCS2LE:
                        m_unicoding = ucr::UCS2LE;
                        m_charsize = 2;
                        break;
-               case CP_UCS2BE:
+               case ucr::CP_UCS2BE:
                        m_unicoding = ucr::UCS2BE;
                        m_charsize = 2;
                        break;
-               case CP_UTF8:
+               case ucr::CP_UTF_8:
                        m_charsize = 1;
                        m_unicoding = ucr::UTF8;
                        break;
index cbdbe97..4c1cdec 100644 (file)
@@ -43,7 +43,6 @@
 #include "ExConverter.h"
 #include "paths.h"
 #include "UniFile.h"
-#include "codepage.h"
 #include "codepage_detect.h"
 #include "Environment.h"
 #include "TFile.h"
@@ -211,7 +210,7 @@ void storageForPlugins::ValidateInternal(bool bNewIsFile, bool bNewIsUnicode)
        m_bCurrentIsFile = bNewIsFile;
        if (bNewIsUnicode)
        {
-               m_codepage = CP_UCS2LE;
+               m_codepage = ucr::CP_UCS2LE;
                m_nBomSize = 2; 
        }
        else
@@ -280,7 +279,7 @@ const TCHAR *storageForPlugins::GetDataFileUnicode()
                                int bom_bytes = ucr::writeBom(shmOut.begin(), ucr::UCS2LE);
                                // to UCS-2 conversion, from unicoder.cpp maketstring
                                bool lossy;
-                               textRealSize = ucr::CrossConvert(pchar, nchars, (char *)shmOut.begin()+bom_bytes, textForeseenSize-1, m_codepage, CP_UCS2LE, &lossy);
+                               textRealSize = ucr::CrossConvert(pchar, nchars, (char *)shmOut.begin()+bom_bytes, textForeseenSize-1, m_codepage, ucr::CP_UCS2LE, &lossy);
                        }
                        // size may have changed
                        fileOut.setSize(textRealSize + bom_bytes);
@@ -357,7 +356,7 @@ BSTR * storageForPlugins::GetDataBufferUnicode()
                        {
                                // to UCS-2 conversion, from unicoder.cpp maketstring
                                bool lossy;
-                               textRealSize = ucr::CrossConvert(pchar, nchars, (char *)pbstrBuffer, textForeseenSize-1, m_codepage, CP_UCS2LE, &lossy);
+                               textRealSize = ucr::CrossConvert(pchar, nchars, (char *)pbstrBuffer, textForeseenSize-1, m_codepage, ucr::CP_UCS2LE, &lossy);
                                SysFreeString(m_bstr);
                                m_bstr = SysAllocStringLen(tempBSTR.get(), textRealSize / sizeof(wchar_t));
                                if (!m_bstr)
@@ -630,13 +629,13 @@ bool AnyCodepageToUTF8(int codepage, const String& filepath, const String& filep
                        if (pexconv)
                        {
                                size_t srcbytes2 = srcbytes;
-                               if (!pexconv->convert(codepage, CP_UTF8, (const unsigned char *)pszBuf+pos, &srcbytes2, (unsigned char *)obuf.begin(), &destbytes))
+                               if (!pexconv->convert(codepage, ucr::CP_UTF_8, (const unsigned char *)pszBuf+pos, &srcbytes2, (unsigned char *)obuf.begin(), &destbytes))
                                        throw "failed to convert file contents to utf-8";
                        }
                        else
                        {
                                bool lossy = false;
-                               destbytes = ucr::CrossConvert((const char *)pszBuf+pos, static_cast<unsigned>(srcbytes), obuf.begin(), static_cast<unsigned>(destbytes), codepage, CP_UTF8, &lossy);
+                               destbytes = ucr::CrossConvert((const char *)pszBuf+pos, static_cast<unsigned>(srcbytes), obuf.begin(), static_cast<unsigned>(destbytes), codepage, ucr::CP_UTF_8, &lossy);
                        }
                        fout.write(obuf.begin(), destbytes);
                        pos += srcbytes;
index 591c45b..8bb664f 100644 (file)
@@ -9,7 +9,6 @@
 #pragma once
 
 #include "UnicodeString.h"
-#include "codepage.h"
 #include <cstdint>
 
 namespace ucr
@@ -29,6 +28,13 @@ struct buffer
        void resize(size_t newSize);
 };
 
+enum
+{
+       CP_UTF_8  = 65001,
+       CP_UCS2LE = 1200,
+       CP_UCS2BE = 1201
+};
+
 /** @brief Known Unicode encodings. */
 enum UNICODESET : char
 {
index 5bb6f7e..f31601c 100644 (file)
@@ -31,7 +31,6 @@
 #include "Plugins.h"
 #include "paths.h"
 #include "unicoder.h"
-#include "codepage.h"
 #include "Environment.h"
 #include "MergeApp.h"
 #include "OptionsMgr.h"
index 6183863..86f8a64 100644 (file)
@@ -26,7 +26,6 @@
 #include "CompareStats.h"
 #include "FolderCmp.h"
 #include "FileFilterHelper.h"
-#include "codepage.h"
 #include "IAbortable.h"
 #include "FolderCmp.h"
 #include "DirItem.h"
index 77ae75b..33f86be 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "FileTextEncoding.h"
 #include "unicoder.h"
-#include "codepage.h"
 
 FileTextEncoding::FileTextEncoding()
 {
@@ -31,13 +30,13 @@ void FileTextEncoding::SetCodepage(int codepage)
        m_codepage = codepage;
        switch (codepage)
        {
-       case CP_UTF8:
+       case ucr::CP_UTF_8:
                m_unicoding = ucr::UTF8;
                break;
-       case CP_UCS2LE:
+       case ucr::CP_UCS2LE:
                m_unicoding = ucr::UCS2LE;
                break;
-       case CP_UCS2BE:
+       case ucr::CP_UCS2BE:
                m_unicoding = ucr::UCS2BE;
                break;
        default:
@@ -54,21 +53,21 @@ void FileTextEncoding::SetUnicoding(ucr::UNICODESET unicoding)
        case ucr::NONE:
                switch (m_codepage)
                {
-               case CP_UTF8:
-               case CP_UCS2LE:
-               case CP_UCS2BE:
+               case ucr::CP_UTF_8:
+               case ucr::CP_UCS2LE:
+               case ucr::CP_UCS2BE:
                        m_codepage = 0; // not sure what to do here
                        break;
                }
                break;
        case ucr::UTF8:
-               m_codepage = CP_UTF8;
+               m_codepage = ucr::CP_UTF_8;
                break;
        case ucr::UCS2LE:
-               m_codepage = CP_UCS2LE;
+               m_codepage = ucr::CP_UCS2LE;
                break;
        case ucr::UCS2BE:
-               m_codepage = CP_UCS2BE;
+               m_codepage = ucr::CP_UCS2BE;
                break;
        }
 }
@@ -95,7 +94,7 @@ String FileTextEncoding::GetName() const
        if (m_codepage <= 0)
                return _T("");
 
-       if (m_codepage == CP_UTF8)
+       if (m_codepage == ucr::CP_UTF_8)
        {
                // We detected codepage to be UTF-8, but unicoding was not set
                return _T("UTF-8");
index 305c6c2..da4f66a 100644 (file)
@@ -80,9 +80,9 @@ bool FilterList::Match(const std::string& string, int codepage/*=CP_UTF8*/)
        // convert string into UTF-8
        ucr::buffer buf(string.length() * 2);
 
-       if (codepage != CP_UTF8)
+       if (codepage != ucr::CP_UTF_8)
                        ucr::convert(ucr::NONE, codepage, reinterpret_cast<const unsigned char *>(string.c_str()), 
-                                       string.length(), ucr::UTF8, CP_UTF8, &buf);
+                                       string.length(), ucr::UTF8, ucr::CP_UTF_8, &buf);
 
        unsigned i = 0;
        while (i < count && retval == false)
index efaaac0..880bce2 100644 (file)
@@ -7,9 +7,8 @@
 
 #include <vector>
 #include <memory>
-#define POCO_NO_UNWINDOWS 1
 #include <Poco/RegularExpression.h>
-#include "codepage.h"
+#include "unicoder.h"
 
 /**
  * @brief Container for one filtering rule / compiled expression.
@@ -41,7 +40,7 @@ public:
        void AddRegExp(const std::string& regularExpression);
        void RemoveAllFilters();
        bool HasRegExps() const;
-       bool Match(const std::string& string, int codepage = CP_UTF8);
+       bool Match(const std::string& string, int codepage = ucr::CP_UTF_8);
        const char * GetLastMatchExpression() const;
 
 private:
index e731f1a..80affb5 100644 (file)
@@ -1905,7 +1905,7 @@ bool CImgMergeFrame::GenerateReport(const String& sFileName) const
                return false;
        }
 
-       file.SetCodepage(CP_UTF8);
+       file.SetCodepage(ucr::CP_UTF_8);
 
        file.WriteString(
                _T("<!DOCTYPE html>\n")
index 4241604..85cc6d5 100644 (file)
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
     <ClCompile Include="Common\CMoveConstraint.cpp" />\r
-    <ClCompile Include="codepage.cpp">\r
-      <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
-    </ClCompile>\r
     <ClCompile Include="codepage_detect.cpp">\r
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
     <ClInclude Include="ChildFrm.h" />\r
     <ClInclude Include="Common\ClipBoard.h" />\r
     <ClInclude Include="Common\CMoveConstraint.h" />\r
-    <ClInclude Include="codepage.h" />\r
     <ClInclude Include="codepage_detect.h" />\r
     <ClInclude Include="Common\ColorButton.h" />\r
     <ClInclude Include="Common\ExConverter.h" />\r
index 8f4a091..7721b65 100644 (file)
@@ -52,9 +52,6 @@
     <ClCompile Include="charsets.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="codepage.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="codepage_detect.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClInclude Include="charsets.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="codepage.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="codepage_detect.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
index 2a3f314..43bf3a5 100644 (file)
@@ -63,6 +63,7 @@
 #include "Merge7zFormatMergePluginImpl.h"
 #include "7zCommon.h"
 #include "PatchTool.h"
+#include "charsets.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -309,7 +310,7 @@ static void SaveBuffForDiff(CDiffTextBuffer & buf, const String& filepath, bool
        {
        // we subvert the buffer's memory of the original file encoding
                buf.setUnicoding(ucr::UTF8);  // write as UTF-8 (for preprocessing)
-               buf.setCodepage(CP_UTF8); // should not matter
+               buf.setCodepage(ucr::CP_UTF_8); // should not matter
                buf.setHasBom(false);
        }
 
@@ -439,7 +440,7 @@ int CMergeDoc::Rescan(bool &bBinary, IDENTLEVEL &identical,
        else
                m_diffWrapper.SetPaths(PathContext(m_tempFiles[0].GetPath(), m_tempFiles[1].GetPath(), m_tempFiles[2].GetPath()), true);
        m_diffWrapper.SetCompareFiles(m_filePaths);
-       m_diffWrapper.SetCodepage(bForceUTF8 ? CP_UTF8 : (m_ptBuf[0]->m_encoding.m_unicoding ? CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage));
+       m_diffWrapper.SetCodepage(bForceUTF8 ? ucr::CP_UTF_8 : (m_ptBuf[0]->m_encoding.m_unicoding ? CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage));
        m_diffWrapper.SetCodepage(m_ptBuf[0]->m_encoding.m_unicoding ?
                        CP_UTF8 : m_ptBuf[0]->m_encoding.m_codepage);
 
@@ -2421,10 +2422,7 @@ bool CMergeDoc::IsValidCodepageForMergeEditor(unsigned cp) const
 {
        if (!cp) // 0 is our signal value for invalid
                return false;
-       // Codepage must be actually installed on system
-       // for us to be able to use it
-       // We accept whatever codepages that codepage module says are installed
-       return true;/*isCodepageInstalled(cp);*/ /* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME */
+       return GetEncodingNameFromCodePage(cp) != NULL;
 }
 
 /**
@@ -3175,7 +3173,7 @@ bool CMergeDoc::GenerateReport(const String& sFileName) const
                return false;
        }
 
-       file.SetCodepage(CP_UTF8);
+       file.SetCodepage(ucr::CP_UTF_8);
 
        String header = 
                string_format(
index 4ff6f0f..261fd87 100644 (file)
@@ -36,7 +36,7 @@ bool UniMarkdownFile::DoOpen(const String& filename, AccessMode mode)
                // CMarkdown wants octets, so we may need to transcode to UTF8.
                // As transcoding strips the BOM, we must check for it in advance.
                if (IsUnicode())
-                       m_codepage = CP_UTF8;
+                       m_codepage = ucr::CP_UTF_8;
                // The CMarkdown::File constructor cares about transcoding.
                CMarkdown::File f(
                        reinterpret_cast<const TCHAR *>(m_base),
diff --git a/Src/codepage.cpp b/Src/codepage.cpp
deleted file mode 100644 (file)
index ff2298f..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//    WinMerge:  an interactive diff/merge utility
-//    Copyright (C) 1997-2000  Thingamahoochie Software
-//    Author: Dean Grimm
-//
-//    This program is free software; you can redistribute it and/or modify
-//    it under the terms of the GNU General Public License as published by
-//    the Free Software Foundation; either version 2 of the License, or
-//    (at your option) any later version.
-//
-//    This program is distributed in the hope that it will be useful,
-//    but WITHOUT ANY WARRANTY; without even the implied warranty of
-//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//    GNU General Public License for more details.
-//
-//    You should have received a copy of the GNU General Public License
-//    along with this program; if not, write to the Free Software
-//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-/////////////////////////////////////////////////////////////////////////////
-/** 
- * @file  codepage.cpp
- */
-
-#include "codepage.h"
-#include <windows.h>
-#include <map>
-#include <cassert>
-#include <tchar.h>
-
-using std::map;
-
-static void initialize();
-
-// map number to bit code
-enum { CP_SUPPORTED_FLAG=0x01, CP_INSTALLED_FLAG=0x10 };
-static map<int, int> f_codepage_status;
-
-/**
- * @brief Callback used by initializeCodepages
- */
-static BOOL CALLBACK EnumInstalledCodePagesProc(LPTSTR lpCodePageString)
-{
-       int codepage = _ttol(lpCodePageString);
-       if (codepage)
-       {
-               f_codepage_status[codepage] |= CP_INSTALLED_FLAG;
-       }
-       return TRUE; // continue enumeration
-}
-
-/**
- * @brief Callback used by initializeCodepages
- */
-static BOOL CALLBACK EnumSupportedCodePagesProc(LPTSTR lpCodePageString)
-{
-       int codepage = _ttol(lpCodePageString);
-       if (codepage)
-       {
-               f_codepage_status[codepage] |= CP_SUPPORTED_FLAG;
-       }
-       return TRUE; // continue enumeration
-}
-
-/**
- * @brief Load information about codepages into local cache
- */
-static void initialize()
-{
-       EnumSystemCodePages(EnumInstalledCodePagesProc, CP_INSTALLED);
-       EnumSystemCodePages(EnumSupportedCodePagesProc, CP_SUPPORTED);
-}
-
-/**
- * @brief Return true if specified codepage is installed on this system (according to EnumSystemCodePages)
- */
-bool isCodepageInstalled(int codepage)
-{
-       static int f_bInitialized = false;
-       if (!f_bInitialized)
-       {
-               initialize();
-               f_bInitialized = true;
-       }
-
-       // the following line will insert an extra element in the map if not already present
-    // but its value will be 0 which means not installed nor supported
-       return (f_codepage_status[codepage] & CP_INSTALLED_FLAG) == CP_INSTALLED_FLAG;
-}
diff --git a/Src/codepage.h b/Src/codepage.h
deleted file mode 100644 (file)
index 76dcef7..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @file  codepage.h
- */
-#pragma once
-
-#ifndef CP_UTF8
-#define CP_UTF8 65001
-#define CP_ACP 0
-#define CP_THREAD_ACP 3
-#endif
-
-#ifndef CP_UCS2LE
-#define CP_UCS2LE 1200
-#define CP_UCS2BE 1201
-#endif
-
-bool isCodepageInstalled(int codepage);
index 17e5fb3..1dc7b60 100644 (file)
@@ -13,7 +13,6 @@
 #include <memory>
 #include "unicoder.h"
 #include "ExConverter.h"
-#include "codepage.h"
 #include "charsets.h"
 #include "FileTextEncoding.h"
 #include "paths.h"
@@ -196,7 +195,7 @@ static unsigned GuessEncoding_from_bytes(const String& ext, const char *src, siz
 {
        unsigned cp = ucr::getDefaultCodepage();
        if (!ucr::CheckForInvalidUtf8(src, len))
-               cp = CP_UTF8;
+               cp = ucr::CP_UTF_8;
        else if (guessEncodingType & 2)
        {
                IExconverter *pexconv = Exconverter::getInstance();
@@ -241,17 +240,17 @@ FileTextEncoding GuessCodepageEncoding(const String& filepath, int guessEncoding
        {
        case 8 + 2 + 0:
                encoding.SetUnicoding(ucr::UCS2LE);
-               encoding.SetCodepage(CP_UCS2LE);
+               encoding.SetCodepage(ucr::CP_UCS2LE);
                encoding.m_bom = true;
                break;
        case 8 + 2 + 1:
                encoding.SetUnicoding(ucr::UCS2BE);
-               encoding.SetCodepage(CP_UCS2BE);
+               encoding.SetCodepage(ucr::CP_UCS2BE);
                encoding.m_bom = true;
                break;
        case 8 + 1:
                encoding.SetUnicoding(ucr::UTF8);
-               encoding.SetCodepage(CP_UTF8);
+               encoding.SetCodepage(ucr::CP_UTF_8);
                encoding.m_bom = true;
                break;
        default:
index b90b5c3..1434e67 100644 (file)
     <ClCompile Include="..\..\..\Src\CompareEngines\ByteComparator.cpp" />\r
     <ClCompile Include="..\..\..\Src\CompareEngines\ByteCompare.cpp" />\r
     <ClCompile Include="..\..\..\Src\charsets.c" />\r
-    <ClCompile Include="..\..\..\Src\codepage.cpp" />\r
     <ClCompile Include="..\..\..\Src\codepage_detect.cpp" />\r
     <ClCompile Include="..\..\..\Src\CompareEngines\TimeSizeCompare.cpp" />\r
     <ClCompile Include="..\..\..\Src\CompareOptions.cpp" />\r
     <ClCompile Include="..\ByteCompare\ByteCompare_test.cpp" />\r
     <ClCompile Include="..\Encoding\charsets_test.cpp" />\r
     <ClCompile Include="..\Encoding\codepage_detect_test.cpp" />\r
-    <ClCompile Include="..\Encoding\codepage_test.cpp" />\r
     <ClCompile Include="..\DirItem\DirItem_test.cpp" />\r
     <ClCompile Include="..\Environment\Environemt_test.cpp" />\r
     <ClCompile Include="..\FileFilter\FileFilterHelper_test.cpp" />\r
     <ClInclude Include="..\..\..\Src\CompareEngines\ByteComparator.h" />\r
     <ClInclude Include="..\..\..\Src\CompareEngines\ByteCompare.h" />\r
     <ClInclude Include="..\..\..\Src\charsets.h" />\r
-    <ClInclude Include="..\..\..\Src\codepage.h" />\r
     <ClInclude Include="..\..\..\Src\codepage_detect.h" />\r
     <ClInclude Include="..\..\..\Src\CompareEngines\TimeSizeCompare.h" />\r
     <ClInclude Include="..\..\..\Src\CompareOptions.h" />\r
index c89a602..ddfcc70 100644 (file)
@@ -30,9 +30,6 @@
     <ClCompile Include="..\..\..\Src\charsets.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\..\..\Src\codepage.cpp">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\..\..\Src\codepage_detect.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="..\Encoding\codepage_detect_test.cpp">\r
       <Filter>Tests</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="..\Encoding\codepage_test.cpp">\r
-      <Filter>Tests</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="..\DirItem\DirItem_test.cpp">\r
       <Filter>Tests</Filter>\r
     </ClCompile>\r
     <ClInclude Include="..\..\..\Src\charsets.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="..\..\..\Src\codepage.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="..\..\..\Src\codepage_detect.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
index a8681bd..54b5164 100644 (file)
@@ -1,5 +1,4 @@
 #include <gtest/gtest.h>
-#include "codepage.h"
 #include "unicoder.h"
 
 namespace
@@ -61,7 +60,7 @@ namespace
                int n;
 
                // UTF8->UCS2LE
-               n = ucr::CrossConvert(str_utf8, strlen(str_utf8), (char *)wbuf, sizeof(wbuf), CP_UTF8, 1200, &lossy);
+               n = ucr::CrossConvert(str_utf8, strlen(str_utf8), (char *)wbuf, sizeof(wbuf), ucr::CP_UTF_8, 1200, &lossy);
                EXPECT_STREQ(str_ucs2, wbuf);
                EXPECT_EQ(wcslen(str_ucs2) * sizeof(wchar_t), n);
 
@@ -77,12 +76,12 @@ namespace
                EXPECT_EQ(wcslen(str_ucs2) * sizeof(wchar_t), n);
 
                // UTF8->UCS2BE
-               n = ucr::CrossConvert(str_utf8, strlen(str_utf8), (char *)wbuf, sizeof(wbuf), CP_UTF8, 1201, &lossy);
+               n = ucr::CrossConvert(str_utf8, strlen(str_utf8), (char *)wbuf, sizeof(wbuf), ucr::CP_UTF_8, 1201, &lossy);
                EXPECT_STREQ(str_ucs2be, wbuf);
                EXPECT_EQ(wcslen(str_ucs2be) * sizeof(wchar_t), n);
 
                // UCS2BE->UTF8
-               n = ucr::CrossConvert((char *)str_ucs2be, wcslen(str_ucs2be) * sizeof(wchar_t), buf, sizeof(buf), 1201, CP_UTF8, &lossy);
+               n = ucr::CrossConvert((char *)str_ucs2be, wcslen(str_ucs2be) * sizeof(wchar_t), buf, sizeof(buf), 1201, ucr::CP_UTF_8, &lossy);
                EXPECT_STREQ(str_utf8, buf);
                EXPECT_EQ(strlen(str_utf8), n);