[dasher: 37/217] Added handy functions to UTF conversion - unused code
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 37/217] Added handy functions to UTF conversion - unused code
- Date: Sat, 27 Feb 2016 12:03:26 +0000 (UTC)
commit d76cbe7234b1ee2c094c9aa84e59101850350cde
Author: ipomoena <amajorek google com>
Date: Fri Sep 18 11:01:44 2015 -0700
Added handy functions to UTF conversion - unused code
Src/DasherCore/DasherCore_vc2013.vcxproj | 4 --
Src/DasherCore/IMEConversionHelper.cpp | 67 ------------------------------
Src/DasherCore/IMEConversionHelper.h | 32 --------------
Src/DasherCore/NodeCreationManager.cpp | 14 ------
Src/Win32/Common/WinUTF8.cpp | 50 +++++-----------------
Src/Win32/Common/WinUTF8.h | 6 +-
Src/Win32/ModuleControlString.cpp | 5 +--
7 files changed, 16 insertions(+), 162 deletions(-)
---
diff --git a/Src/DasherCore/DasherCore_vc2013.vcxproj b/Src/DasherCore/DasherCore_vc2013.vcxproj
index ff504d1..6af2e89 100644
--- a/Src/DasherCore/DasherCore_vc2013.vcxproj
+++ b/Src/DasherCore/DasherCore_vc2013.vcxproj
@@ -244,7 +244,6 @@
<ClCompile Include="FileWordGenerator.cpp" />
<ClCompile Include="FrameRate.cpp" />
<ClCompile Include="GameModule.cpp" />
- <ClCompile Include="IMEConversionHelper.cpp" />
<ClCompile Include="LanguageModelling\CTWLanguageModel.cpp" />
<ClCompile Include="LanguageModelling\DictLanguageModel.cpp" />
<ClCompile Include="LanguageModelling\HashTable.cpp" />
@@ -329,9 +328,6 @@
<ClInclude Include="FrameRate.h" />
<ClInclude Include="GameModule.h" />
<ClInclude Include="GameStatistics.h" />
- <CustomBuild Include="IMEConversionHelper.h">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Mobile
Debug|Win32'">true</ExcludedFromBuild>
- </CustomBuild>
<ClInclude Include="InputFilter.h" />
<ClInclude Include="LanguageModelling\CTWLanguageModel.h" />
<ClInclude Include="LanguageModelling\DictLanguageModel.h" />
diff --git a/Src/DasherCore/NodeCreationManager.cpp b/Src/DasherCore/NodeCreationManager.cpp
index 1f14e2b..7b405e7 100644
--- a/Src/DasherCore/NodeCreationManager.cpp
+++ b/Src/DasherCore/NodeCreationManager.cpp
@@ -60,20 +60,6 @@ CNodeCreationManager::CNodeCreationManager(CSettingsUser *pCreateFrom,
case 0: // No conversion required
m_pAlphabetManager = new CAlphabetManager(this, pInterface, this, pAlphInfo);
break;
-#ifdef JAPANESE
- case 1: {
- // Japanese
- CConversionManager *pConversionManager =
-#ifdef _WIN32
- new CIMEConversionHelper;
-#else
- new CCannaConversionHelper(this, pAlphInfo, GetLongParameter(LP_CONVERSION_TYPE),
GetLongParameter(LP_CONVERSION_ORDER));
-#endif
- //TODO ownership/deletion
- m_pAlphabetManager = new CConvertingAlphMgr(pInterface, this, pConversionManager, pAlphInfo,
pLanguageModel);
- break;
- }
-#endif
case 2:
//Mandarin Dasher!
//(ACL) Modify AlphabetManager for Mandarin Dasher
diff --git a/Src/Win32/Common/WinUTF8.cpp b/Src/Win32/Common/WinUTF8.cpp
index 6bfef7b..3c548da 100644
--- a/Src/Win32/Common/WinUTF8.cpp
+++ b/Src/Win32/Common/WinUTF8.cpp
@@ -22,10 +22,6 @@ static char THIS_FILE[] = __FILE__;
/*
-DJW 20050505
-If CP_UTF8 is defined we use Windows native UTF-8 conversion.
-Otherwise we include extra code from the Unicode consortium to do it for us.
-
IAM 09/2002
Warning2: TODO: Error checking is non-existent. I am very naughty. This needs
sorting out.
@@ -37,24 +33,6 @@ using std::wstring;
/////////////////////////////////////////////////////////////////////////////
-#ifndef CP_UTF8 // MultiByteToWideChar(CP_UTF8,...) won't work
-namespace {
-#include "../../Common/Unicode/ConvertUTF.c" // Yes I do mean to include .c
-}
-#endif /* #ifndef CP_UTF8 */
-
-/*
-ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
-*/
-
-/////////////////////////////////////////////////////////////////////////////
-
void WinUTF8::UTF8string_to_wstring(const std::string &UTF8string, std::wstring &Output) {
// Optimization - use the stack for small strings
const std::size_t iStackBufferSize = 32;
@@ -69,14 +47,7 @@ void WinUTF8::UTF8string_to_wstring(const std::string &UTF8string, std::wstring
bNewed = true;
}
-#ifdef CP_UTF8
MultiByteToWideChar(CP_UTF8, 0, UTF8string.c_str(), -1, pBuffer, BufferSize);
-#else // Some OS's don't support this (Win95, WinCE if this code is ported there)
- const UTF8 *sourceStart = (const UTF8 *)UTF8string.c_str(); // yuck
- UTF16 *targetStart = pBuffer;
- ConvertUTF8toUTF16(&sourceStart, sourceStart + UTF8string.size(), &targetStart, targetStart + BufferSize -
1, lenientConversion);
- *targetStart = 0; // Null-terminate the converted string
-#endif
Output = pBuffer;
if(bNewed)
@@ -94,21 +65,24 @@ std::wstring WinUTF8::UTF8string_to_wstring(const std::string &utf8string) {
/////////////////////////////////////////////////////////////////////////////
void WinUTF8::wstring_to_UTF8string(const wstring &Input, string &Output) {
+ wstring_to_UTF8string(Input.c_str(), Output);
+}
+
+string WinUTF8::wstring_to_UTF8string(const wchar_t *Input) {
+ string res;
+ wstring_to_UTF8string(Input, res);
+ return res;
+}
+
+void WinUTF8::wstring_to_UTF8string(const wchar_t *Input, string &Output) {
- const std::size_t BufferSize = Input.size() + 1;
- const wchar_t *Buffer = Input.c_str();
+ const std::size_t BufferSize = wcslen(Input) + 1;
+ const wchar_t *Buffer = Input;
const std::size_t BufferSize2 = BufferSize * 2;
char *Buffer2 = new char[BufferSize2];
-#ifdef CP_UTF8
WideCharToMultiByte(CP_UTF8, 0, Buffer, -1, Buffer2, BufferSize2, NULL, NULL);
-#else
- const UTF16 *sourceStart = Buffer;
- UTF8 *targetStart = (UTF8 *) Buffer2;
- ConvertUTF16toUTF8(&sourceStart, sourceStart + len, &targetStart, targetStart + BufferSize2 - 1,
lenientConversion);
- *targetStart = 0; // Null-terminate the converted string
-#endif /* #ifdef CP_UTF8 */
Output = Buffer2;
delete[]Buffer2;
diff --git a/Src/Win32/Common/WinUTF8.h b/Src/Win32/Common/WinUTF8.h
index 1c89a9b..40c7d8f 100644
--- a/Src/Win32/Common/WinUTF8.h
+++ b/Src/Win32/Common/WinUTF8.h
@@ -14,9 +14,7 @@
wstring is UTF-16, probably constrained to the BMP,
such that all codepoints are represented in two bytes.
- These functions are just wrappers around Windows API calls or functions
- from the Unicode consortium (if using Windows 95 or CE, which do not support
- UTF-8 natively).
+ These functions are just wrappers around Windows API calls.
}}}*/
#include <string>
@@ -25,5 +23,7 @@ namespace WinUTF8 {
void UTF8string_to_wstring(const std::string & UTF8string, std::wstring & Output);
std::wstring UTF8string_to_wstring(const std::string &UTF8string);
void wstring_to_UTF8string(const std::wstring & Input, std::string & Output);
+ void wstring_to_UTF8string(const wchar_t *Input, std::string &Output);
+ std::string wstring_to_UTF8string(const wchar_t* Input);
}
#endif /* #ifndef __WinUTF8_h__ */
diff --git a/Src/Win32/ModuleControlString.cpp b/Src/Win32/ModuleControlString.cpp
index 44a8546..0938587 100644
--- a/Src/Win32/ModuleControlString.cpp
+++ b/Src/Win32/ModuleControlString.cpp
@@ -9,10 +9,7 @@ void CModuleControlString::Initialise(CAppSettings *pAppSets) {
void CModuleControlString::Apply(CAppSettings *pAppSets) {
CString wideText;
m_hEntry.GetWindowText(wideText);
- std::string strUTF8Text;
- WinUTF8::wstring_to_UTF8string(std::wstring(wideText), strUTF8Text);
-
- pAppSets->SetStringParameter(m_iId, strUTF8Text);
+ pAppSets->SetStringParameter(m_iId, WinUTF8::wstring_to_UTF8string(wideText));
}
void CModuleControlString::CreateChild(HWND hParent, RECT& rect) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]