diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-11-01 22:06:13 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-11-01 22:06:13 +0900 |
| commit | fd0136259c0673d21e1b07dfa8359a81748f8499 (patch) | |
| tree | 2b42974d326f5bd379e8610ac43168ff370db041 /src | |
| parent | 3a8e8f8e8a351d179018ecd8cdcf87fef6214007 (diff) | |
Remove nativeToUtf8 and utf8ToNative
They are now not needed since we use Windows specific command-line
argument converter.
Diffstat (limited to 'src')
| -rw-r--r-- | src/option_processing.cc | 18 | ||||
| -rw-r--r-- | src/util.cc | 51 | ||||
| -rw-r--r-- | src/util.h | 4 |
3 files changed, 4 insertions, 69 deletions
diff --git a/src/option_processing.cc b/src/option_processing.cc index 8e0474ab..9be3a09e 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -176,20 +176,6 @@ void showCandidates } // namespace -#ifdef __MINGW32__ -namespace { -void optionNativeToUtf8(Option& op) -{ - for(size_t i = 1, len = option::countOption(); i < len; ++i) { - PrefPtr pref = option::i2p(i); - if(op.definedLocal(pref) && !util::isUtf8(op.get(pref))) { - op.put(pref, nativeToUtf8(op.get(pref))); - } - } -} -} // namespace -#endif // __MINGW32__ - error_code::Value option_processing(Option& op, bool standalone, std::vector<std::string>& uris, int argc, char** argv, @@ -290,10 +276,6 @@ error_code::Value option_processing(Option& op, bool standalone, op.setParent(confOption); oparser->parse(op, cmdstream); oparser->parse(op, options); -#ifdef __MINGW32__ - optionNativeToUtf8(op); - optionNativeToUtf8(*confOption); -#endif // __MINGW32__ } catch(OptionHandlerException& e) { global::cerr()->printf("%s", e.stackTrace().c_str()); const OptionHandler* h = oparser->find(e.getPref()); diff --git a/src/util.cc b/src/util.cc index 528c3cb1..053475db 100644 --- a/src/util.cc +++ b/src/util.cc @@ -106,29 +106,16 @@ int utf8ToWChar(wchar_t* out, size_t outLength, const char* src) } // namespace namespace { -int ansiToWChar(wchar_t* out, size_t outLength, const char* src) -{ - return MultiByteToWideChar(CP_ACP, 0, src, -1, out, outLength); -} -} // namespace - -namespace { int wCharToUtf8(char* out, size_t outLength, const wchar_t* src) { - return WideCharToMultiByte(CP_UTF8, 0, src, -1, out, outLength, 0, 0); -} -} // namespace - -namespace { -int wCharToAnsi(char* out, size_t outLength, const wchar_t* src) -{ - return WideCharToMultiByte(CP_ACP, 0, src, -1, out, outLength, 0, 0); + return WideCharToMultiByte(CP_UTF8, 0, src, -1, out, outLength, + nullptr, nullptr); } } // namespace std::wstring utf8ToWChar(const char* src) { - int len = utf8ToWChar(0, 0, src); + int len = utf8ToWChar(nullptr, 0, src); if(len <= 0) { abort(); } @@ -146,25 +133,9 @@ std::wstring utf8ToWChar(const std::string& src) return utf8ToWChar(src.c_str()); } -std::string utf8ToNative(const std::string& src) -{ - std::wstring wsrc = utf8ToWChar(src); - int len = wCharToAnsi(0, 0, wsrc.c_str()); - if(len <= 0) { - abort(); - } - auto buf = make_unique<char[]>((size_t)len); - len = wCharToAnsi(buf.get(), len, wsrc.c_str()); - if(len <= 0) { - abort(); - } else { - return buf.get(); - } -} - std::string wCharToUtf8(const std::wstring& wsrc) { - int len = wCharToUtf8(0, 0, wsrc.c_str()); + int len = wCharToUtf8(nullptr, 0, wsrc.c_str()); if(len <= 0) { abort(); } @@ -177,20 +148,6 @@ std::string wCharToUtf8(const std::wstring& wsrc) } } -std::string nativeToUtf8(const std::string& src) -{ - int len = ansiToWChar(0, 0, src.c_str()); - if(len <= 0) { - abort(); - } - auto buf = make_unique<wchar_t[]>((size_t)len); - len = ansiToWChar(buf.get(), len, src.c_str()); - if(len <= 0) { - abort(); - } else { - return wCharToUtf8(std::wstring(buf.get())); - } -} #endif // __MINGW32__ namespace util { @@ -103,11 +103,7 @@ std::wstring utf8ToWChar(const std::string& src); std::wstring utf8ToWChar(const char* str); -std::string utf8ToNative(const std::string& src); - std::string wCharToUtf8(const std::wstring& wsrc); - -std::string nativeToUtf8(const std::string& src); #else // !__MINGW32__ # define utf8ToWChar(src) src # define utf8ToNative(src) src |
