2 * @file FileTextEncoding.cpp
4 * @brief Implementation of FileTextEncoding structure
6 // ID line follows -- this is updated by SVN
7 // $Id: FileTextEncoding.cpp 7172 2010-05-19 12:57:18Z jtuc $
9 #include "FileTextEncoding.h"
13 FileTextEncoding::FileTextEncoding()
19 * @brief Forget any encoding info we have
21 void FileTextEncoding::Clear()
24 m_unicoding = ucr::NONE;
32 void FileTextEncoding::SetCodepage(int codepage)
34 m_codepage = codepage;
38 m_unicoding = ucr::UTF8;
41 m_unicoding = ucr::UCS2LE;
44 m_unicoding = ucr::UCS2BE;
47 m_unicoding = ucr::NONE;
52 void FileTextEncoding::SetUnicoding(ucr::UNICODESET unicoding)
54 m_unicoding = unicoding;
63 m_codepage = 0; // not sure what to do here
71 m_codepage = CP_UCS2LE;
74 m_codepage = CP_UCS2BE;
80 * @brief Return string representation of encoding, eg "UCS-2LE", or "1252"
81 * @todo This resource lookup should be done in GUI code?
83 String FileTextEncoding::GetName() const
85 if (m_unicoding == ucr::UTF8)
88 return _T("UTF-8 (B)");
93 if (m_unicoding == ucr::UCS2LE)
94 return _T("UCS-2 LE");
95 if (m_unicoding == ucr::UCS2BE)
96 return _T("UCS-2 BE");
101 if (m_codepage == CP_UTF8)
103 // We detected codepage to be UTF-8, but unicoding was not set
107 return string_to_str(m_codepage);
110 int FileTextEncoding::Collate(const FileTextEncoding & fte1, const FileTextEncoding & fte2)
112 if (fte1.m_unicoding > fte2.m_unicoding)
114 if (fte1.m_unicoding < fte2.m_unicoding)
116 if (fte1.m_codepage > fte2.m_codepage)
118 if (fte1.m_codepage < fte2.m_codepage)