summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/demo/Ice/MFC/client/HelloClientDlg.cpp2
-rw-r--r--cpp/demo/IceGrid/icebox/HelloI.cpp2
-rw-r--r--cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp15
-rw-r--r--cpp/include/IceUtil/Exception.h24
-rw-r--r--cpp/include/IceUtil/IceUtil.h2
-rw-r--r--cpp/include/IceUtil/StringConverter.h91
-rw-r--r--cpp/include/IceUtil/Unicode.h57
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp4
-rw-r--r--cpp/src/Ice/Exception.cpp8
-rw-r--r--cpp/src/Ice/Initialize.cpp2
-rw-r--r--cpp/src/Ice/Network.cpp26
-rw-r--r--cpp/src/Ice/PropertiesI.cpp12
-rw-r--r--cpp/src/Ice/Service.cpp20
-rw-r--r--cpp/src/Ice/ThreadPool.cpp6
-rw-r--r--cpp/src/IceGrid/Activator.cpp22
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp6
-rw-r--r--cpp/src/IceGrid/ServerI.cpp4
-rw-r--r--cpp/src/IcePatch2/Calc.cpp1
-rw-r--r--cpp/src/IcePatch2/FileServerI.cpp1
-rw-r--r--cpp/src/IcePatch2Lib/ClientUtil.cpp2
-rw-r--r--cpp/src/IcePatch2Lib/Util.cpp6
-rw-r--r--cpp/src/IceUtil/ConvertUTF.cpp1
-rw-r--r--cpp/src/IceUtil/ConvertUTF.h2
-rw-r--r--cpp/src/IceUtil/Exception.cpp56
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp40
-rw-r--r--cpp/src/IceUtil/StringConverter.cpp67
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp2
-rw-r--r--cpp/src/IceUtil/Unicode.cpp107
-rw-r--r--cpp/src/IceXML/Parser.cpp1
-rw-r--r--cpp/src/Slice/Parser.cpp1
-rw-r--r--cpp/src/Slice/Preprocessor.cpp3
-rw-r--r--cpp/src/Slice/Util.cpp1
-rw-r--r--cpp/src/iceserviceinstall/ServiceInstaller.cpp62
-rw-r--r--cpp/test/Ice/custom/StringConverterI.cpp5
-rw-r--r--cpp/test/Ice/stringConverter/Server.cpp8
-rw-r--r--cpp/test/IceGrid/deployer/Server.cpp6
-rw-r--r--cpp/test/IceUtil/inputUtil/Client.cpp1
-rw-r--r--cpp/test/IceUtil/unicode/Client.cpp17
38 files changed, 267 insertions, 426 deletions
diff --git a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp
index 640f8328ffe..dc85c224411 100644
--- a/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp
+++ b/cpp/demo/Ice/MFC/client/HelloClientDlg.cpp
@@ -390,7 +390,7 @@ CHelloClientDlg::createProxy()
{
CString h;
_host->GetWindowText(h);
- string host = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, wstring(h));
+ string host = IceUtil::wstringToString(wstring(h), IceUtil::getProcessStringConverter());
if(host.size() == 0)
{
_status->SetWindowText(CString(" No hostname"));
diff --git a/cpp/demo/IceGrid/icebox/HelloI.cpp b/cpp/demo/IceGrid/icebox/HelloI.cpp
index 1e96d635ba9..dd30feaaddb 100644
--- a/cpp/demo/IceGrid/icebox/HelloI.cpp
+++ b/cpp/demo/IceGrid/icebox/HelloI.cpp
@@ -25,7 +25,7 @@ HelloI::sayHello(const Ice::Current&)
buf.resize(1024);
DWORD val = GetEnvironmentVariableW(L"LANG", &buf[0], static_cast<DWORD>(buf.size()));
string lang = (val > 0 && val < buf.size()) ?
- IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, &buf[0]) : string("en");
+ IceUtil::wstringToString(&buf[0], IceUtil::getProcessStringConverter()) : string("en");
#else
char* val = getenv("LANG");
string lang = val ? string(val) : "en";
diff --git a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp
index 015cfb31458..537c0b26ac0 100644
--- a/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp
+++ b/cpp/demo/IcePatch2/MFC/PatchClientDlg.cpp
@@ -148,7 +148,7 @@ CPatchDlg::checksumProgress(const string& path)
// TODO: indicate busy progress
CString file;
- file.Format(L" %s", IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, getBasename(path)).c_str());
+ file.Format(L" %s", IceUtil::stringToWstring(getBasename(path)).c_str());
_file->SetWindowText(file);
processMessages();
@@ -206,7 +206,7 @@ CPatchDlg::patchStart(const string& path, Ice::Long size, Ice::Long totalProgres
}
CString file;
- file.Format(L" %s", IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, getBasename(path)).c_str());
+ file.Format(L" %s", IceUtil::stringToWstring(getBasename(path)).c_str());
_file->SetWindowText(file);
return patchProgress(0, size, totalProgress, totalSize);
@@ -294,18 +294,15 @@ CPatchDlg::OnInitDialog()
// Set the patch directory and thorough flag from properties.
//
Ice::PropertiesPtr properties = _communicator->getProperties();
- CString path = IceUtil::nativeToWnative(
- IceUtil::getProcessStringConverter(), 0,
+ CString path = IceUtil::stringToWstring(
properties->getPropertyWithDefault("IcePatch2Client.Directory", "")).c_str();
_path->SetWindowText(path);
- CString thorough = IceUtil::nativeToWnative(
- IceUtil::getProcessStringConverter(), 0,
+ CString thorough = IceUtil::stringToWstring(
properties->getPropertyWithDefault("IcePatch2Client.Thorough", "0")).c_str();
_thorough->SetCheck(thorough != "0");
- CString remove = IceUtil::nativeToWnative(
- IceUtil::getProcessStringConverter(), 0,
+ CString remove = IceUtil::stringToWstring(
properties->getPropertyWithDefault("IcePatch2Client.Remove", "0")).c_str();
_remove->SetCheck(remove != "0");
@@ -402,7 +399,7 @@ CPatchDlg::OnStartPatch()
return;
}
properties->setProperty("IcePatch2Client.Directory",
- IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, wstring(path)));
+ IceUtil::wstringToString(wstring(path)));
//
// Set the thorough patch flag.
diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h
index b3dca7824d5..b285bed56c3 100644
--- a/cpp/include/IceUtil/Exception.h
+++ b/cpp/include/IceUtil/Exception.h
@@ -78,9 +78,31 @@ public:
private:
static const char* _name;
- std::string _reason;
+ const std::string _reason;
+};
+
+//
+// IllegalConversionException is raised to report a string conversion error
+//
+class ICE_UTIL_API IllegalConversionException : public Exception
+{
+public:
+
+ IllegalConversionException(const char*, int);
+ IllegalConversionException(const char*, int, const std::string&);
+ virtual std::string ice_name() const;
+ virtual void ice_print(std::ostream&) const;
+ virtual IllegalConversionException* ice_clone() const;
+ virtual void ice_throw() const;
+
+ std::string reason() const;
+private:
+
+ static const char* _name;
+ const std::string _reason;
};
+
class ICE_UTIL_API SyscallException : public Exception
{
public:
diff --git a/cpp/include/IceUtil/IceUtil.h b/cpp/include/IceUtil/IceUtil.h
index b5e126a34c2..15f16c26a8a 100644
--- a/cpp/include/IceUtil/IceUtil.h
+++ b/cpp/include/IceUtil/IceUtil.h
@@ -33,12 +33,12 @@
#include <IceUtil/RecMutex.h>
#include <IceUtil/ScopedArray.h>
#include <IceUtil/Shared.h>
+#include <IceUtil/StringConverter.h>
#include <IceUtil/Thread.h>
#include <IceUtil/ThreadException.h>
#include <IceUtil/Time.h>
#include <IceUtil/Timer.h>
#include <IceUtil/UUID.h>
-#include <IceUtil/Unicode.h>
#include <IceUtil/UniquePtr.h>
#ifndef _WIN32
diff --git a/cpp/include/IceUtil/StringConverter.h b/cpp/include/IceUtil/StringConverter.h
index b3e8d62f2b7..8f82cbd984a 100644
--- a/cpp/include/IceUtil/StringConverter.h
+++ b/cpp/include/IceUtil/StringConverter.h
@@ -11,39 +11,26 @@
#include <IceUtil/Exception.h>
#include <IceUtil/Shared.h>
#include <IceUtil/Handle.h>
-#include <IceUtil/Unicode.h>
#include <string>
namespace IceUtil
{
-//
-// Raised by string converters when an encoding converseion fails.
-//
-class ICE_UTIL_API IllegalConversionException : public ::IceUtil::Exception
+enum ConversionFlags
{
-public:
-
- IllegalConversionException(const char*, int);
- IllegalConversionException(const char*, int, const ::std::string&);
- virtual ~IllegalConversionException() throw();
-
- virtual ::std::string ice_name() const;
- virtual void ice_print(::std::ostream&) const;
- virtual IllegalConversionException* ice_clone() const;
- virtual void ice_throw() const;
+ strictConversion = 0,
+ lenientConversion
+};
- std::string reason() const;
-
-private:
+typedef unsigned char Byte;
- std::string _reason;
-};
+ICE_UTIL_API bool
+isLegalUTF8Sequence(const Byte* source, const Byte* end);
//
-// Provides bytes to toUTF8. Raises MemoryLimitException when too many
-// bytes are requested.
+// Provides bytes to toUTF8. Can raise std::bad_alloc or Ice::MemoryLimitException
+// when too many bytes are requested.
//
class ICE_UTIL_API UTF8Buffer
{
@@ -56,7 +43,8 @@ public:
//
// A StringConverter converts narrow or wide-strings to and from UTF-8 byte sequences.
// It's used by the communicator during marshaling (toUTF8) and unmarshaling (fromUTF8).
-// It report errors by raising IllegalConversionException or MemoryLimitException.
+// It report errors by raising IllegalConversionException or an exception raised
+// by UTF8Buffer
//
template<typename charT>
class BasicStringConverter : public IceUtil::Shared
@@ -144,50 +132,49 @@ ICE_UTIL_API WstringConverterPtr getProcessWstringConverter();
//
ICE_UTIL_API void setProcessWstringConverter(const WstringConverterPtr&);
-//
-// Convert the given wide string from the native wide string encoding to a
-// narrow string with the native narrow string encoding.
-//
-// The StringConverter param can be null in that case the default narrow
-// string encoding is assumed to be UTF8.
-//
-// The WstringConverter param can be null in that case the default wide
-// string encoding is assumed, that would be UTF16 or UTF32 depending of
-// the platform.
-//
-ICE_UTIL_API std::string
-wnativeToNative(const StringConverterPtr&, const WstringConverterPtr&, const std::wstring&);
-
-//
-// Convert the given narrow string from the native narrow string encoding
-// to a wide string with the native wide string encoding.
-//
-// The StringConverter param can be null in that case the default narrow
-// string encoding is assumed to be UTF8.
-//
-// The WstringConverter param can be null in that case the default wide
-// string encoding is assumed, that would be UTF16 or UTF32 depending of
-// the platform.
-//
-ICE_UTIL_API std::wstring
-nativeToWnative(const StringConverterPtr&, const WstringConverterPtr&, const std::string&);
//
// Converts the given string from the native narrow string encoding to
-// UTF8 using the given converter. If the converter is null, returns
+// UTF-8 using the given converter. If the converter is null, returns
// the given string.
//
ICE_UTIL_API std::string
nativeToUTF8(const StringConverterPtr&, const std::string&);
//
-// Converts the given string from UTF8 to the native narrow string
+// Converts the given string from UTF-88 to the native narrow string
// encoding using the given converter. If the converter is null,
// returns the given string.
//
ICE_UTIL_API std::string
UTF8ToNative(const StringConverterPtr&, const std::string&);
+
+//
+// Converts the given wide string to a narrow string
+//
+// If the StringConverter parameter is null, the result's narrow
+// string encoding is UTF-8.
+// If the WstringConverter parameter is null, the input's wstring
+// encoding is UTF-16 or UTF-32 depending on the size of wchar_t.
+//
+ICE_UTIL_API std::string
+wstringToString(const std::wstring&, const StringConverterPtr& = 0,
+ const WstringConverterPtr& = 0, ConversionFlags = lenientConversion);
+
+//
+// Converts the given narrow string to a wide string
+//
+// If the StringConverter parameter is null, the input's narrow string
+// encoding is UTF-8.
+// If the WstringConverter parameter is null, the result's wstring
+// encoding is UTF-16 or UTF-32 depending on the size of wchar_t.
+//
+ICE_UTIL_API std::wstring
+stringToWstring(const std::string&, const StringConverterPtr& = 0,
+ const WstringConverterPtr& = 0, ConversionFlags = lenientConversion);
+
+
}
#endif
diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h
index 71a52b3e62f..7108467fc16 100644
--- a/cpp/include/IceUtil/Unicode.h
+++ b/cpp/include/IceUtil/Unicode.h
@@ -11,56 +11,7 @@
#define ICE_UTIL_UNICODE_H
#include <IceUtil/Config.h>
-#include <IceUtil/Exception.h>
-
-namespace IceUtil
-{
-
-enum ConversionFlags
-{
- strictConversion = 0,
- lenientConversion
-};
-
-ICE_DEPRECATED_API std::string
-wstringToString(const std::wstring&, ConversionFlags = lenientConversion);
-
-ICE_DEPRECATED_API std::wstring
-stringToWstring(const std::string&, ConversionFlags = lenientConversion);
-
-typedef unsigned char Byte;
-
-ICE_UTIL_API bool
-isLegalUTF8Sequence(const Byte* source, const Byte* end);
-
-enum ConversionError
-{
- partialCharacter,
- badEncoding
-};
-
-//
-// UTFConversionException is raised by wstringToString() or stringToWstring()
-// to report a conversion error
-//
-class ICE_UTIL_API UTFConversionException : public Exception
-{
-public:
-
- UTFConversionException(const char*, int, ConversionError);
- virtual std::string ice_name() const;
- virtual void ice_print(std::ostream&) const;
- virtual UTFConversionException* ice_clone() const;
- virtual void ice_throw() const;
-
- ConversionError conversionError() const;
-private:
-
- const ConversionError _conversionError;
- static const char* _name;
-};
-
-}
+#include <IceUtil/StringConverter.h>
namespace IceUtilInternal
{
@@ -81,15 +32,15 @@ enum ConversionResult
sourceIllegal /* source sequence is illegal/malformed */
};
-ICE_UTIL_API ConversionResult
+ConversionResult
convertUTFWstringToUTF8(const wchar_t*& sourceStart, const wchar_t* sourceEnd,
IceUtil::Byte*& targetStart, IceUtil::Byte* targetEnd, IceUtil::ConversionFlags flags);
-ICE_UTIL_API ConversionResult
+ConversionResult
convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd,
wchar_t*& targetStart, wchar_t* targetEnd, IceUtil::ConversionFlags flags);
-ICE_UTIL_API ConversionResult
+ConversionResult
convertUTF8ToUTFWstring(const IceUtil::Byte*& sourceStart, const IceUtil::Byte* sourceEnd,
std::wstring& target, IceUtil::ConversionFlags flags);
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index 1fa6c86ad73..702eda02254 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -202,9 +202,9 @@ IceInternal::DynamicLibrary::load(const string& lib)
// to Windows API.
//
#ifdef ICE_OS_WINRT
- _hnd = LoadPackagedLibrary(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, lib).c_str(), 0);
+ _hnd = LoadPackagedLibrary(IceUtil::stringToWstring(lib, IceUtil::getProcessStringConverter()).c_str(), 0);
#elif defined(_WIN32)
- _hnd = LoadLibraryW(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, lib).c_str());
+ _hnd = LoadLibraryW(IceUtil::stringToWstring(lib, IceUtil::getProcessStringConverter()).c_str());
#else
int flags = RTLD_NOW | RTLD_GLOBAL;
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index d503e480eb2..c3824d95dbd 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -16,7 +16,7 @@
#include <Ice/Stream.h>
#include <IceUtil/StringUtil.h>
#ifdef ICE_OS_WINRT
-# include <IceUtil/Unicode.h>
+# include <IceUtil/StringConverter.h>
#endif
#include <iomanip>
@@ -48,9 +48,9 @@ socketErrorToString(int error)
// Don't need to use a wide string converter as the wide string come
// from Windows API.
//
- return IceUtil::wnativeToNative(
- IceUtil::getProcessStringConverter(), 0,
- static_cast<Windows::Networking::Sockets::SocketErrorStatus>(error).ToString()->Data());
+ return IceUtil::wstringToString(
+ static_cast<Windows::Networking::Sockets::SocketErrorStatus>(error).ToString()->Data(),
+ IceUtil::getProcessStringConverter());
}
#else
return IceUtilInternal::errorToString(error);
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index bb54e11c537..a53f6add939 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -91,7 +91,7 @@ Ice::argsToStringSeq(int /*argc*/, wchar_t* argv[])
StringSeq args;
for(int i=0; argv[i] != 0; i++)
{
- args.push_back(IceUtil::wnativeToNative(converter, 0, argv[i]));
+ args.push_back(IceUtil::wstringToString(argv[i], converter));
}
return args;
}
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 4108dd23053..a7b13e875d0 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -31,7 +31,7 @@
#include <IceUtil/DisableWarnings.h>
#include <Ice/Network.h>
#include <IceUtil/StringUtil.h>
-#include <IceUtil/Unicode.h>
+#include <IceUtil/StringConverter.h>
#include <Ice/LocalException.h>
#include <Ice/Properties.h> // For setTcpBufSize
#include <Ice/LoggerUtil.h> // For setTcpBufSize
@@ -520,7 +520,7 @@ getInterfaceIndex(const string& name)
// Don't need to pass a wide string converter as the wide string
// come from Windows API.
//
- if(IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, paddrs->FriendlyName) == name)
+ if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name)
{
index = paddrs->Ipv6IfIndex;
break;
@@ -664,7 +664,7 @@ getInterfaceAddress(const string& name)
// Don't need to pass a wide string converter as the wide string come
// from Windows API.
//
- if(IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, paddrs->FriendlyName) == name)
+ if(IceUtil::wstringToString(paddrs->FriendlyName, IceUtil::getProcessStringConverter()) == name)
{
struct sockaddr_in addrin;
memcpy(&addrin, paddrs->FirstUnicastAddress->Address.lpSockaddr,
@@ -892,7 +892,7 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En
// to Windows API.
//
addr.host = ref new HostName(ref new String(
- IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, host).c_str()));
+ IceUtil::stringToWstring(host, IceUtil::getProcessStringConverter()).c_str()));
}
stringstream os;
os << port;
@@ -900,7 +900,7 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport, Ice::En
// Don't need to use any string converter here as the port number use just
// ACII characters.
//
- addr.port = ref new String(IceUtil::nativeToWnative(0, 0, os.str()).c_str());
+ addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
result.push_back(addr);
return result;
}
@@ -1066,9 +1066,9 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p
os << port;
//
// Don't need to use any string converter here as the port number use just
- // ACII characters.
+ // ASCII characters.
//
- addr.port = ref new String(IceUtil::nativeToWnative(0, 0, os.str()).c_str());
+ addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
addr.host = nullptr; // Equivalent of inaddr_any, see doBind implementation.
#else
memset(&addr.saStorage, 0, sizeof(sockaddr_storage));
@@ -1548,7 +1548,7 @@ IceInternal::inetAddrToString(const Address& ss)
// Don't need to pass a wide string converter as the wide string come
// from Windows API.
//
- return IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, ss.host->RawName->Data());
+ return IceUtil::wstringToString(ss.host->RawName->Data(), IceUtil::getProcessStringConverter());
}
#endif
}
@@ -1572,9 +1572,9 @@ IceInternal::getPort(const Address& addr)
#else
IceUtil::Int64 port;
//
- // Don't need to use any string converter here as the port number use just ACII characters.
+ // Don't need to use any string converter here as the port number use just ASCII characters.
//
- if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wnativeToNative(0, 0, addr.port->Data()), port))
+ if(addr.port == nullptr || !IceUtilInternal::stringToInt64(IceUtil::wstringToString(addr.port->Data()), port))
{
return -1;
}
@@ -1602,7 +1602,7 @@ IceInternal::setPort(Address& addr, int port)
// Don't need to use any string converter here as the port number use just
// ACII characters.
//
- addr.port = ref new String(IceUtil::nativeToWnative(0, 0, os.str()).c_str());
+ addr.port = ref new String(IceUtil::stringToWstring(os.str()).c_str());
#endif
}
@@ -1627,7 +1627,7 @@ IceInternal::isMulticast(const Address& addr)
// Don't need to use string converters here, this is just to do a local
// comparison to find if the address is multicast.
//
- string host = IceUtil::wnativeToNative(0, 0, addr.host->RawName->Data());
+ string host = IceUtil::wstringToString(addr.host->RawName->Data());
string ip = IceUtilInternal::toUpper(host);
vector<string> tokens;
IceUtilInternal::splitString(ip, ".", tokens);
@@ -2533,7 +2533,7 @@ IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, Hos
// Don't need to pass a wide string converter as the wide string come from
// Windows API.
//
- ex.host = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, host->RawName->Data());
+ ex.host = IceUtil::wstringToString(host->RawName->Data(), IceUtil::getProcessStringConverter());
throw ex;
}
else
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index b8642c3af78..b466a2cf105 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -303,7 +303,7 @@ Ice::PropertiesI::load(const std::string& file)
if(file.find("HKLM\\") == 0)
{
HKEY iceKey;
- const wstring keyName = IceUtil::nativeToWnative(_converter, 0, file).substr(5).c_str();
+ const wstring keyName = IceUtil::stringToWstring(file, _converter).substr(5).c_str();
LONG err;
if((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.c_str(), 0, KEY_QUERY_VALUE, &iceKey)) != ERROR_SUCCESS)
{
@@ -350,8 +350,8 @@ Ice::PropertiesI::load(const std::string& file)
getProcessLogger()->warning(os.str());
continue;
}
- string name = IceUtil::wnativeToNative(_converter, 0,
- wstring(reinterpret_cast<wchar_t*>(&nameBuf[0]), nameBufSize));
+ string name = IceUtil::wstringToString(
+ wstring(reinterpret_cast<wchar_t*>(&nameBuf[0]), nameBufSize), _converter);
if(keyType != REG_SZ && keyType != REG_EXPAND_SZ)
{
ostringstream os;
@@ -364,7 +364,7 @@ Ice::PropertiesI::load(const std::string& file)
wstring valueW = wstring(reinterpret_cast<wchar_t*>(&dataBuf[0]), (dataBufSize / sizeof(wchar_t)) - 1);
if(keyType == REG_SZ)
{
- value = IceUtil::wnativeToNative(_converter, 0, valueW);
+ value = IceUtil::wstringToString(valueW, _converter);
}
else // keyType == REG_EXPAND_SZ
{
@@ -384,7 +384,7 @@ Ice::PropertiesI::load(const std::string& file)
continue;
}
}
- value = IceUtil::wnativeToNative(_converter, 0, wstring(&expandedValue[0], sz -1));
+ value = IceUtil::wstringToString(wstring(&expandedValue[0], sz -1), _converter);
}
setProperty(name, value);
}
@@ -728,7 +728,7 @@ Ice::PropertiesI::loadConfig()
}
if(ret > 0)
{
- value = IceUtil::wnativeToNative(_converter, 0, wstring(&v[0], ret));
+ value = IceUtil::wstringToString(wstring(&v[0], ret), _converter);
}
else
{
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 13631d3209b..c775c1c6e5f 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -211,7 +211,7 @@ public:
// Don't need to use a wide string converter as the wide string is passed
// to Windows API.
//
- _source = RegisterEventSourceW(0, IceUtil::nativeToWnative(_stringConverter, 0, mangleSource(source)).c_str());
+ _source = RegisterEventSourceW(0, IceUtil::stringToWstring(mangleSource(source), _stringConverter).c_str());
if(_source == 0)
{
SyscallException ex(__FILE__, __LINE__);
@@ -236,7 +236,7 @@ public:
// to Windows API.
//
LONG err = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
- IceUtil::nativeToWnative(stringConverter, 0, createKey(source)).c_str(),
+ IceUtil::stringToWstring(createKey(source), stringConverter).c_str(),
0, const_cast<wchar_t*>(L"REG_SZ"), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d);
if(err != ERROR_SUCCESS)
@@ -296,7 +296,7 @@ public:
// to Windows API.
//
LONG err = RegDeleteKeyW(HKEY_LOCAL_MACHINE,
- IceUtil::nativeToWnative(stringConverter, 0, createKey(source)).c_str());
+ IceUtil::stringToWstring(createKey(source), stringConverter).c_str());
if(err != ERROR_SUCCESS)
{
SyscallException ex(__FILE__, __LINE__);
@@ -325,7 +325,7 @@ public:
// Don't need to use a wide string converter as the wide string is passed
// to Windows API.
//
- wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message);
+ wstring msg = IceUtil::stringToWstring(message, _stringConverter);
const wchar_t* messages[1];
messages[0] = msg.c_str();
//
@@ -363,7 +363,7 @@ public:
// Don't need to use a wide string converter as the wide string is passed
// to Windows API.
//
- wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, s);
+ wstring msg = IceUtil::stringToWstring(s, _stringConverter);
const wchar_t* messages[1];
messages[0] = msg.c_str();
//
@@ -393,7 +393,7 @@ public:
// Don't need to use a wide string converter as the wide string is passed
// to Windows API.
//
- wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message);
+ wstring msg = IceUtil::stringToWstring(message, _stringConverter);
const wchar_t* messages[1];
messages[0] = msg.c_str();
//
@@ -423,7 +423,7 @@ public:
// Don't need to use a wide string converter as the wide string is passed
// to Windows API.
//
- wstring msg = IceUtil::nativeToWnative(_stringConverter, 0, message);
+ wstring msg = IceUtil::stringToWstring(message, _stringConverter);
const wchar_t* messages[1];
messages[0] = msg.c_str();
//
@@ -1117,7 +1117,7 @@ Ice::Service::runService(int argc, char* argv[], const InitializationData& initD
SERVICE_TABLE_ENTRYW ste[] =
{
{ const_cast<wchar_t*>(
- IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, _name).c_str()),
+ IceUtil::stringToWstring(_name, IceUtil::getProcessStringConverter()).c_str()),
Ice_Service_ServiceMain },
{ 0, 0 },
};
@@ -1305,7 +1305,7 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[])
// as argv come from Windows API.
//
char** args = new char*[_serviceArgs.size() + argc];
- args[0] = const_cast<char*>(IceUtil::wnativeToNative(converter, 0, argv[0]).c_str());
+ args[0] = const_cast<char*>(IceUtil::wstringToString(argv[0], converter).c_str());
int i = 1;
for(vector<string>::iterator p = _serviceArgs.begin(); p != _serviceArgs.end(); ++p)
{
@@ -1313,7 +1313,7 @@ Ice::Service::serviceMain(int argc, wchar_t* argv[])
}
for(int j = 1; j < argc; ++j)
{
- args[i++] = const_cast<char*>(IceUtil::wnativeToNative(converter, 0, argv[j]).c_str());
+ args[i++] = const_cast<char*>(IceUtil::wstringToString(argv[j], converter).c_str());
}
argc += static_cast<int>(_serviceArgs.size());
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index e0c1680c745..f806e276267 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -28,7 +28,7 @@
#include <Ice/TraceLevels.h>
#if defined(ICE_OS_WINRT)
-# include <IceUtil/Unicode.h>
+# include <IceUtil/StringConverter.h>
#endif
using namespace std;
@@ -959,12 +959,12 @@ IceInternal::ThreadPool::run(const EventHandlerThreadPtr& thread)
catch(Platform::Exception^ ex)
{
//
- // We don't need to pass the wide string converter in the call to wnativeToNative
+ // We don't need to pass the wide string converter in the call to wstringToString
// because the wide string is using the platform default encoding.
//
Error out(_instance->initializationData().logger);
out << "exception in `" << _prefix << "':\n"
- << IceUtil::wnativeToNative(_instance->getStringConverter(), 0, ex->Message->Data())
+ << IceUtil::wstringToString(ex->Message->Data(), _instance->getStringConverter())
<< "\nevent handler: " << current._handler->toString();
}
#endif
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 1b1bb3f6d04..c67ab7af6fe 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -380,9 +380,9 @@ Activator::activate(const string& name,
//
// IceGrid doesn't support to use string converters, so don't need to use
- // any string converter in wnativeToNative conversions.
+ // any string converter in wstringToString conversions.
//
- if(SearchPathW(NULL, IceUtil::nativeToWnative(0, 0, path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0)
+ if(SearchPathW(NULL, IceUtil::stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0)
{
if(_traceLevels->activator > 0)
{
@@ -391,7 +391,7 @@ Activator::activate(const string& name,
}
throw string("Couldn't find `" + path + "' executable.");
}
- path = IceUtil::wnativeToNative(0, 0, absbuf);
+ path = IceUtil::wstringToString(absbuf);
}
else if(!pwd.empty())
{
@@ -403,13 +403,13 @@ Activator::activate(const string& name,
// Get the absolute pathname of the working directory.
//
// IceGrid doesn't support to use string converters, so
- // don't need to use any string converter in nativeToWnative
+ // don't need to use any string converter in stringToWstring
// conversions.
//
if(!pwd.empty())
{
wchar_t absbuf[_MAX_PATH];
- if(_wfullpath(absbuf, IceUtil::nativeToWnative(0, 0, pwd).c_str(), _MAX_PATH) == NULL)
+ if(_wfullpath(absbuf, IceUtil::stringToWstring(pwd).c_str(), _MAX_PATH) == NULL)
{
if(_traceLevels->activator > 0)
{
@@ -418,7 +418,7 @@ Activator::activate(const string& name,
}
throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
}
- pwd = IceUtil::wnativeToNative(0, 0, absbuf);
+ pwd = IceUtil::wstringToString(absbuf);
}
#endif
@@ -495,15 +495,15 @@ Activator::activate(const string& name,
//
// IceGrid doesn't support to use string converters, so don't need to use
- // any string converter in nativeToWnative conversions.
+ // any string converter in stringToWstring conversions.
//
- wstring wpwd = IceUtil::nativeToWnative(0, 0, pwd);
+ wstring wpwd = IceUtil::stringToWstring(pwd);
const wchar_t* dir = !wpwd.empty() ? wpwd.c_str() : NULL;
//
// Make a copy of the command line.
//
- wchar_t* cmdbuf = _wcsdup(IceUtil::nativeToWnative(0, 0, cmd).c_str());
+ wchar_t* cmdbuf = _wcsdup(IceUtil::stringToWstring(cmd).c_str());
//
// Create the environment block for the child process. We start with the environment
@@ -545,9 +545,9 @@ Activator::activate(const string& name,
{
//
// IceGrid doesn't support to use string converters, so don't need to use
- // any string converter in nativeToWnative conversions.
+ // any string converter in stringToWstring conversions.
//
- wstring s = IceUtil::nativeToWnative(0, 0, *p);
+ wstring s = IceUtil::stringToWstring(*p);
wstring::size_type pos = s.find(L'=');
if(pos != wstring::npos)
{
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index 68ef989fb45..bc7683bb6af 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -126,11 +126,7 @@ private:
void
setNoIndexingAttribute(const string& pa)
{
- //
- // We don't need to pass a wide string converter the wide
- // string is passed to Windows API.
- //
- wstring path = IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, pa);
+ wstring path = IceUtil::stringToWstring(pa);
DWORD attrs = GetFileAttributesW(path.c_str());
if(attrs == INVALID_FILE_ATTRIBUTES)
{
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 7adbb72bb6a..283496dce8c 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -405,9 +405,9 @@ struct EnvironmentEval : std::unary_function<string, string>
break;
}
string variable = v.substr(beg + 1, end - beg - 1);
- DWORD ret = GetEnvironmentVariableW(IceUtil::nativeToWnative(0, 0, variable).c_str(), &buf[0],
+ DWORD ret = GetEnvironmentVariableW(IceUtil::stringToWstring(variable).c_str(), &buf[0],
static_cast<DWORD>(buf.size()));
- string valstr = (ret > 0 && ret < buf.size()) ? IceUtil::wnativeToNative(0, 0, &buf[0]) : string("");
+ string valstr = (ret > 0 && ret < buf.size()) ? IceUtil::wstringToString(&buf[0]) : string("");
v.replace(beg, end - beg + 1, valstr);
beg += valstr.size();
}
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index fe8d7cb1ee6..b87c5e48c72 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -8,7 +8,6 @@
// **********************************************************************
#include <IceUtil/Options.h>
-#include <IceUtil/Unicode.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
#include <IcePatch2/Util.h>
diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp
index 0441b9f6a11..66adf90ebec 100644
--- a/cpp/src/IcePatch2/FileServerI.cpp
+++ b/cpp/src/IcePatch2/FileServerI.cpp
@@ -10,7 +10,6 @@
#include <IceUtil/DisableWarnings.h>
#include <IceUtil/FileUtil.h>
#include <IceUtil/ScopedArray.h>
-#include <IceUtil/Unicode.h>
#include <IcePatch2/FileServerI.h>
#ifdef _WIN32
diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp
index 82d0dce208d..3c7eee1aeb8 100644
--- a/cpp/src/IcePatch2Lib/ClientUtil.cpp
+++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp
@@ -7,10 +7,8 @@
//
// **********************************************************************
-#include <IceUtil/Unicode.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
-#include <IceUtil/StringConverter.h>
#define ICE_PATCH2_API_EXPORTS
#include <IcePatch2/ClientUtil.h>
#include <IcePatch2/Util.h>
diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp
index 2fc00be9d7c..d743528d531 100644
--- a/cpp/src/IcePatch2Lib/Util.cpp
+++ b/cpp/src/IcePatch2Lib/Util.cpp
@@ -424,10 +424,10 @@ IcePatch2::readDirectory(const string& pa)
//
// IcePatch2 doesn't support to use string converters, so don't need to use
- // any string converter in nativeToWnative or wnativeToNative conversions.
+ // any string converter in stringToWstring or wstringToString conversions.
//
StringSeq result;
- const wstring fs = IceUtil::nativeToWnative(0, 0, simplify(path + "/*"));
+ const wstring fs = IceUtil::stringToWstring(simplify(path + "/*"));
struct _wfinddata_t data;
intptr_t h = _wfindfirst(fs.c_str(), &data);
@@ -438,7 +438,7 @@ IcePatch2::readDirectory(const string& pa)
while(true)
{
- string name = IceUtil::wnativeToNative(0, 0, data.name);
+ string name = IceUtil::wstringToString(data.name);
assert(!name.empty());
if(name != ".." && name != ".")
diff --git a/cpp/src/IceUtil/ConvertUTF.cpp b/cpp/src/IceUtil/ConvertUTF.cpp
index d6abc324738..0797c332062 100644
--- a/cpp/src/IceUtil/ConvertUTF.cpp
+++ b/cpp/src/IceUtil/ConvertUTF.cpp
@@ -49,6 +49,7 @@
#include <IceUtil/ConvertUTF.h>
+#include <IceUtil/StringConverter.h>
#ifdef CVTUTF_DEBUG
#include <stdio.h>
diff --git a/cpp/src/IceUtil/ConvertUTF.h b/cpp/src/IceUtil/ConvertUTF.h
index ce182b74213..17a638f320c 100644
--- a/cpp/src/IceUtil/ConvertUTF.h
+++ b/cpp/src/IceUtil/ConvertUTF.h
@@ -135,7 +135,7 @@ ConversionResult ConvertUTF32toUTF8(
UTF8** targetStart, UTF8* targetEnd, IceUtil::ConversionFlags flags);
//
-// isLegalUTFSequence is declared in IceUtil/Unicode.h
+// isLegalUTFSequence is declared in IceUtil/StringConverter.h
//
/* --------------------------------------------------------------------- */
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index 8498a6a5f55..36d3e017899 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -224,14 +224,14 @@ getStackTrace()
//
// Don't need to use pass a wide string converter in the bellow
- // calls to wnativeToNative as the wide strings come from
+ // calls to wstringToString as the wide strings come from
// Windows API.
//
BOOL ok = SymFromAddr(process, address, 0, symbol);
if(ok)
{
#ifdef DBGHELP_TRANSLATE_TCHAR
- s << IceUtil::wnativeToNative(converter, 0, symbol->Name);
+ s << IceUtil::wstringToString(symbol->Name, converter);
#else
s << symbol->Name;
#endif
@@ -240,7 +240,7 @@ getStackTrace()
{
s << " at line " << line.LineNumber << " in "
#ifdef DBGHELP_TRANSLATE_TCHAR
- << IceUtil::wnativeToNative(converter, 0, line.FileName);
+ << IceUtil::wstringToString(line.FileName, converter);
#else
<< line.FileName;
#endif
@@ -552,6 +552,56 @@ IceUtil::IllegalArgumentException::reason() const
return _reason;
}
+//
+// IllegalConversionException
+//
+
+const char* IceUtil::IllegalConversionException::_name = "IceUtil::IllegalConversionException";
+
+IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line):
+ Exception(file, line)
+{}
+
+IceUtil::IllegalConversionException::IllegalConversionException(const char* file, int line,
+ const string& reason):
+ Exception(file, line),
+ _reason(reason)
+{}
+
+string
+IceUtil::IllegalConversionException::ice_name() const
+{
+ return _name;
+}
+
+void
+IceUtil::IllegalConversionException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ": " << _reason;
+
+}
+
+IceUtil::IllegalConversionException*
+IceUtil::IllegalConversionException::ice_clone() const
+{
+ return new IllegalConversionException(*this);
+}
+
+void
+IceUtil::IllegalConversionException::ice_throw() const
+{
+ throw *this;
+}
+
+string
+IceUtil::IllegalConversionException::reason() const
+{
+ return _reason;
+}
+
+
+
IceUtil::SyscallException::SyscallException(const char* file, int line, int err ):
Exception(file, line),
_error(err)
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index d9080a3c62d..89379f5f3b6 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -104,8 +104,8 @@ IceUtilInternal::freopen(const std::string& path, const std::string& mode, FILE*
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return _wfreopen(IceUtil::nativeToWnative(converter, 0, path).c_str(),
- IceUtil::nativeToWnative(converter, 0, mode).c_str(), stderr);
+ return _wfreopen(IceUtil::stringToWstring(path, converter).c_str(),
+ IceUtil::stringToWstring(mode, converter).c_str(), stderr);
# else
return freopen(path.c_str(), mode.c_str(), stderr);
# endif
@@ -124,13 +124,13 @@ IceUtilInternal::stat(const string& path, structstat* buffer)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return _wstat(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), buffer);
+ return _wstat(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), buffer);
}
int
IceUtilInternal::remove(const string& path)
{
- return ::_wremove(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str());
+ return ::_wremove(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -141,8 +141,8 @@ IceUtilInternal::rename(const string& from, const string& to)
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return ::_wrename(IceUtil::nativeToWnative(converter, 0, from).c_str(),
- IceUtil::nativeToWnative(converter, 0, to).c_str());
+ return ::_wrename(IceUtil::stringToWstring(from, converter).c_str(),
+ IceUtil::stringToWstring(to, converter).c_str());
}
int
@@ -152,7 +152,7 @@ IceUtilInternal::rmdir(const string& path)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return ::_wrmdir(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str());
+ return ::_wrmdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -162,7 +162,7 @@ IceUtilInternal::mkdir(const string& path, int)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return ::_wmkdir(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str());
+ return ::_wmkdir(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
FILE*
@@ -173,8 +173,8 @@ IceUtilInternal::fopen(const string& path, const string& mode)
// to Windows API.
//
const IceUtil::StringConverterPtr converter = IceUtil::getProcessStringConverter();
- return ::_wfopen(IceUtil::nativeToWnative(converter, 0, path).c_str(),
- IceUtil::nativeToWnative(converter, 0, mode).c_str());
+ return ::_wfopen(IceUtil::stringToWstring(path, converter).c_str(),
+ IceUtil::stringToWstring(mode, converter).c_str());
}
int
@@ -186,12 +186,12 @@ IceUtilInternal::open(const string& path, int flags)
//
if(flags & _O_CREAT)
{
- return ::_wopen(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(),
+ return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
flags, _S_IREAD | _S_IWRITE);
}
else
{
- return ::_wopen(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), flags);
+ return ::_wopen(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), flags);
}
}
@@ -208,7 +208,7 @@ IceUtilInternal::getcwd(string& cwd)
{
return -1;
}
- cwd = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, cwdbuf);
+ cwd = IceUtil::wstringToString(cwdbuf, IceUtil::getProcessStringConverter());
return 0;
}
#endif
@@ -220,7 +220,7 @@ IceUtilInternal::unlink(const string& path)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- return _wunlink(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str());
+ return _wunlink(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str());
}
int
@@ -242,12 +242,12 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) :
// to Windows API.
//
#ifndef ICE_OS_WINRT
- _fd = ::CreateFileW(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(),
+ _fd = ::CreateFileW(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
#else
CREATEFILE2_EXTENDED_PARAMETERS params;
params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
- _fd = ::CreateFile2(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(),
+ _fd = ::CreateFile2(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(),
GENERIC_WRITE, 0, OPEN_ALWAYS, &params);
#endif
_path = path;
@@ -306,7 +306,7 @@ IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- std::ifstream(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode)
+ std::ifstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode)
#endif
{
}
@@ -321,7 +321,7 @@ IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- std::ifstream::open(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode);
+ std::ifstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode);
#endif
}
@@ -337,7 +337,7 @@ IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- std::ofstream(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode)
+ std::ofstream(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode)
#endif
{
}
@@ -352,7 +352,7 @@ IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode)
// Don't need to use a wide string converter, the wide string is directly passed
// to Windows API.
//
- std::ofstream::open(IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(), 0, path).c_str(), mode);
+ std::ofstream::open(IceUtil::stringToWstring(path, IceUtil::getProcessStringConverter()).c_str(), mode);
#endif
}
diff --git a/cpp/src/IceUtil/StringConverter.cpp b/cpp/src/IceUtil/StringConverter.cpp
index 9b4d6e2c8f2..c76a636ac17 100644
--- a/cpp/src/IceUtil/StringConverter.cpp
+++ b/cpp/src/IceUtil/StringConverter.cpp
@@ -4,6 +4,7 @@
#include <IceUtil/Mutex.h>
#include <IceUtil/ScopedArray.h>
#include <IceUtil/StringUtil.h>
+#include <IceUtil/Unicode.h>
using namespace IceUtil;
using namespace IceUtilInternal;
@@ -34,54 +35,6 @@ public:
Init init;
-const char* __IceUtil__IllegalConversionException_name = "IceUtil::IllegalConversionException";
-
-}
-
-IllegalConversionException::IllegalConversionException(const char* file, int line) :
- ::IceUtil::Exception(file, line)
-{
-}
-
-IllegalConversionException::IllegalConversionException(const char* file, int line, const string& reason) :
- ::IceUtil::Exception(file, line),
- _reason(reason)
-{
-}
-
-IllegalConversionException::~IllegalConversionException() throw()
-{
-}
-
-string
-IllegalConversionException::ice_name() const
-{
- return __IceUtil__IllegalConversionException_name;
-}
-
-void
-IllegalConversionException::ice_print(ostream& out) const
-{
- Exception::ice_print(out);
- out << ": " << _reason;
-}
-
-IceUtil::IllegalConversionException*
-IllegalConversionException::ice_clone() const
-{
- return new IllegalConversionException(*this);
-}
-
-void
-IllegalConversionException::ice_throw() const
-{
- throw *this;
-}
-
-string
-IllegalConversionException::reason() const
-{
- return _reason;
}
@@ -197,7 +150,8 @@ IceUtil::UTF8ToNative(const IceUtil::StringConverterPtr& converter, const string
}
string
-IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConverterPtr& wConverter, const wstring& v)
+IceUtil::wstringToString(const wstring& v, const StringConverterPtr& converter, const WstringConverterPtr& wConverter,
+ IceUtil::ConversionFlags flags)
{
string target;
if(!v.empty())
@@ -224,14 +178,14 @@ IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConve
ConversionResult cr =
convertUTFWstringToUTF8(
sourceStart, sourceStart + v.size(),
- targetStart, targetEnd, lenientConversion);
+ targetStart, targetEnd, flags);
if(cr != conversionOK)
{
delete[] outBuf;
assert(cr == sourceExhausted || cr == sourceIllegal);
- throw UTFConversionException(__FILE__, __LINE__,
- cr == sourceExhausted ? partialCharacter : badEncoding);
+ throw IllegalConversionException(__FILE__, __LINE__,
+ cr == sourceExhausted ? "partial character" : "bad encoding");
}
target = string(reinterpret_cast<char*>(outBuf), static_cast<size_t>(targetStart - outBuf));
@@ -254,7 +208,8 @@ IceUtil::wnativeToNative(const StringConverterPtr& converter, const WstringConve
}
wstring
-IceUtil::nativeToWnative(const StringConverterPtr& converter, const WstringConverterPtr& wConverter, const string& v)
+IceUtil::stringToWstring(const string& v, const StringConverterPtr& converter,
+ const WstringConverterPtr& wConverter, IceUtil::ConversionFlags flags)
{
wstring target;
if(!v.empty())
@@ -288,14 +243,14 @@ IceUtil::nativeToWnative(const StringConverterPtr& converter, const WstringConve
const Byte* sourceStart = reinterpret_cast<const Byte*>(tmp.data());
ConversionResult cr =
- convertUTF8ToUTFWstring(sourceStart, sourceStart + tmp.size(), target, lenientConversion);
+ convertUTF8ToUTFWstring(sourceStart, sourceStart + tmp.size(), target, flags);
if(cr != conversionOK)
{
assert(cr == sourceExhausted || cr == sourceIllegal);
- throw UTFConversionException(__FILE__, __LINE__,
- cr == sourceExhausted ? partialCharacter : badEncoding);
+ throw IllegalConversionException(__FILE__, __LINE__,
+ cr == sourceExhausted ? "partial character" : "bad encoding");
}
}
}
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 16d7c9f18bf..e8b234f91e3 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -575,7 +575,7 @@ IceUtilInternal::errorToString(int error, LPCVOID source)
LocalFree(msg);
}
#endif
- return wnativeToNative(getProcessStringConverter(), getProcessWstringConverter(), result);
+ return wstringToString(result, getProcessStringConverter(), getProcessWstringConverter());
}
else
{
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index 14da4fb3b5a..ad6e2e659bd 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -129,110 +129,3 @@ IceUtilInternal::convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* s
}
-//
-// wstringToString and stringToWstring
-//
-
-const char* IceUtil::UTFConversionException::_name = "IceUtil::UTFConversionException";
-
-IceUtil::UTFConversionException::UTFConversionException(const char* file, int line,
- ConversionError ce):
- Exception(file, line),
- _conversionError(ce)
-{}
-
-string
-IceUtil::UTFConversionException::ice_name() const
-{
- return _name;
-}
-
-void
-IceUtil::UTFConversionException::ice_print(ostream& os) const
-{
- Exception::ice_print(os);
- switch(_conversionError)
- {
- case partialCharacter:
- os << ": partial character";
- break;
- case badEncoding:
- os << ": bad encoding";
- break;
- default:
- assert(0);
- break;
- };
-}
-
-IceUtil::UTFConversionException*
-IceUtil::UTFConversionException::ice_clone() const
-{
- return new UTFConversionException(*this);
-}
-
-void
-IceUtil::UTFConversionException::ice_throw() const
-{
- throw *this;
-}
-
-IceUtil::ConversionError
-IceUtil::UTFConversionException::conversionError() const
-{
- return _conversionError;
-}
-
-
-string
-IceUtil::wstringToString(const wstring& wstr, ConversionFlags flags)
-{
- string target;
-
- size_t size = wstr.size() * 3 * (sizeof(wchar_t) / 2);
-
- Byte* outBuf = new Byte[size];
- Byte* targetStart = outBuf;
- Byte* targetEnd = outBuf + size;
-
- const wchar_t* sourceStart = wstr.data();
-
- ConversionResult cr =
- convertUTFWstringToUTF8(
- sourceStart, sourceStart + wstr.size(),
- targetStart, targetEnd, flags);
-
- if(cr != conversionOK)
- {
- delete[] outBuf;
- assert(cr == sourceExhausted || cr == sourceIllegal);
- throw UTFConversionException(__FILE__, __LINE__,
- cr == sourceExhausted ? partialCharacter : badEncoding);
- }
-
- string s(reinterpret_cast<char*>(outBuf),
- static_cast<size_t>(targetStart - outBuf));
- s.swap(target);
- delete[] outBuf;
- return target;
-}
-
-wstring
-IceUtil::stringToWstring(const string& str, ConversionFlags flags)
-{
- wstring result;
- const Byte* sourceStart = reinterpret_cast<const Byte*>(str.data());
-
- ConversionResult cr
- = convertUTF8ToUTFWstring(sourceStart, sourceStart + str.size(),
- result, flags);
-
- if(cr != conversionOK)
- {
- assert(cr == sourceExhausted || cr == sourceIllegal);
-
- throw UTFConversionException(__FILE__, __LINE__,
- cr == sourceExhausted ? partialCharacter : badEncoding);
- }
- return result;
-}
diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp
index 2087b9d4cbf..c37974c75d0 100644
--- a/cpp/src/IceXML/Parser.cpp
+++ b/cpp/src/IceXML/Parser.cpp
@@ -8,7 +8,6 @@
// **********************************************************************
#include <IceXML/Parser.h>
-#include <IceUtil/Unicode.h>
#include <IceUtil/FileUtil.h>
#include <expat.h>
#include <list>
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index aedac4d3070..ea79a4f1399 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -10,7 +10,6 @@
#include <IceUtil/Functional.h>
#include <IceUtil/InputUtil.h>
#include <IceUtil/StringUtil.h>
-#include <IceUtil/Unicode.h>
#include <Slice/Parser.h>
#include <Slice/GrammarUtil.h>
#include <Slice/Util.h>
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index da37e868ef9..07519ca2c34 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -14,7 +14,6 @@
#include <IceUtil/StringConverter.h>
#include <IceUtil/FileUtil.h>
#include <IceUtil/UUID.h>
-#include <IceUtil/Unicode.h>
#include <algorithm>
#include <fstream>
#include <sys/types.h>
@@ -237,7 +236,7 @@ Slice::Preprocessor::preprocess(bool keepComments, const string& extraArgs)
// Don't need to pass a wide string converter the wide string
// come from Windows API.
//
- _cppFile = IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(), 0, name);
+ _cppFile = IceUtil::wstringToString(name, IceUtil::getProcessStringConverter());
free(name);
_cppHandle = IceUtilInternal::fopen(_cppFile, "w+");
}
diff --git a/cpp/src/Slice/Util.cpp b/cpp/src/Slice/Util.cpp
index 0fdec1b728d..d7362c18692 100644
--- a/cpp/src/Slice/Util.cpp
+++ b/cpp/src/Slice/Util.cpp
@@ -8,7 +8,6 @@
// **********************************************************************
#include <Slice/Util.h>
-#include <IceUtil/Unicode.h>
#include <IceUtil/FileUtil.h>
#include <IceUtil/StringUtil.h>
#include <climits>
diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.cpp b/cpp/src/iceserviceinstall/ServiceInstaller.cpp
index 527484d1f26..714a4b695a4 100644
--- a/cpp/src/iceserviceinstall/ServiceInstaller.cpp
+++ b/cpp/src/iceserviceinstall/ServiceInstaller.cpp
@@ -269,22 +269,22 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
SC_HANDLE service = CreateServiceW(
scm,
- IceUtil::nativeToWnative(0, 0, _serviceName).c_str(),
- IceUtil::nativeToWnative(0, 0, displayName).c_str(),
+ IceUtil::stringToWstring(_serviceName).c_str(),
+ IceUtil::stringToWstring(displayName).c_str(),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
autoStart ? SERVICE_AUTO_START : SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
- IceUtil::nativeToWnative(0, 0, command).c_str(),
+ IceUtil::stringToWstring(command).c_str(),
0,
0,
- IceUtil::nativeToWnative(0, 0, deps).c_str(),
- IceUtil::nativeToWnative(0, 0, _sidName).c_str(),
- IceUtil::nativeToWnative(0, 0, password).c_str());
+ IceUtil::stringToWstring(deps).c_str(),
+ IceUtil::stringToWstring(_sidName).c_str(),
+ IceUtil::stringToWstring(password).c_str());
if(service == 0)
{
@@ -296,7 +296,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
//
// Set description
//
- wstring uDescription = IceUtil::nativeToWnative(0, 0, description);
+ wstring uDescription = IceUtil::stringToWstring(description);
SERVICE_DESCRIPTIONW sd = { const_cast<wchar_t*>(uDescription.c_str()) };
if(!ChangeServiceConfig2W(service, SERVICE_CONFIG_DESCRIPTION, &sd))
@@ -323,9 +323,9 @@ IceServiceInstaller::uninstall()
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- SC_HANDLE service = OpenServiceW(scm, IceUtil::nativeToWnative(0, 0, _serviceName).c_str(), SERVICE_ALL_ACCESS);
+ SC_HANDLE service = OpenServiceW(scm, IceUtil::stringToWstring(_serviceName).c_str(), SERVICE_ALL_ACCESS);
if(service == 0)
{
DWORD res = GetLastError();
@@ -421,10 +421,10 @@ IceServiceInstaller::initializeSid(const string& name)
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
SID_NAME_USE nameUse;
- while(LookupAccountNameW(0, IceUtil::nativeToWnative(0, 0, name).c_str(), _sidBuffer.get(), &sidSize, domainName.get(),
+ while(LookupAccountNameW(0, IceUtil::stringToWstring(name).c_str(), _sidBuffer.get(), &sidSize, domainName.get(),
&domainNameSize, &nameUse) == false)
{
DWORD res = GetLastError();
@@ -469,7 +469,7 @@ IceServiceInstaller::initializeSid(const string& name)
throw "Could not retrieve full account name for " + name + ": " + IceUtilInternal::errorToString(res);
}
- _sidName = IceUtil::wnativeToNative(0, 0, domainName) + "\\" + IceUtil::wnativeToNative(0, 0, accountName);
+ _sidName = IceUtil::wstringToString(domainName) + "\\" + IceUtil::wstringToString(accountName);
}
if(_debug)
@@ -477,7 +477,7 @@ IceServiceInstaller::initializeSid(const string& name)
Trace trace(_communicator->getLogger(), "IceServiceInstaller");
wchar_t* sidString = 0;
ConvertSidToStringSidW(_sid, &sidString);
- trace << "SID: " << IceUtil::wnativeToNative(0, 0, sidString) << "; ";
+ trace << "SID: " << IceUtil::wstringToString(sidString) << "; ";
LocalFree(sidString);
trace << "Full name: " << _sidName;
}
@@ -522,9 +522,9 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
PSECURITY_DESCRIPTOR sd = 0;
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- DWORD res = GetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::nativeToWnative(0, 0, path).c_str()), type,
+ DWORD res = GetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::stringToWstring(path).c_str()), type,
DACL_SECURITY_INFORMATION, 0, 0, &acl, 0, &sd);
if(res != ERROR_SUCCESS)
{
@@ -608,9 +608,9 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- res = SetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::nativeToWnative(0, 0, path).c_str()), type,
+ res = SetNamedSecurityInfoW(const_cast<wchar_t*>(IceUtil::stringToWstring(path).c_str()), type,
DACL_SECURITY_INFORMATION, 0, 0, newAcl, 0);
if(res != ERROR_SUCCESS)
{
@@ -641,9 +641,9 @@ IceServiceInstaller::mkdir(const string& path) const
{
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- if(CreateDirectoryW(IceUtil::nativeToWnative(0, 0, path).c_str(), 0) == 0)
+ if(CreateDirectoryW(IceUtil::stringToWstring(path).c_str(), 0) == 0)
{
DWORD res = GetLastError();
if(res == ERROR_ALREADY_EXISTS)
@@ -680,9 +680,9 @@ IceServiceInstaller::addLog(const string& log) const
DWORD disposition = 0;
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createLog(log)).c_str(), 0, L"REG_SZ",
+ LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str(), 0, L"REG_SZ",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition);
if(res != ERROR_SUCCESS)
@@ -702,9 +702,9 @@ IceServiceInstaller::removeLog(const string& log) const
{
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
- LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createLog(log)).c_str());
+ LONG res = RegDeleteKeyW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createLog(log)).c_str());
//
// We get ERROR_ACCESS_DENIED when the log is shared by several sources
@@ -720,11 +720,11 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st
{
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
HKEY key = 0;
DWORD disposition = 0;
- LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::nativeToWnative(0, 0, createSource(source, log)).c_str(),
+ LONG res = RegCreateKeyExW(HKEY_LOCAL_MACHINE, IceUtil::stringToWstring(createSource(source, log)).c_str(),
0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &key, &disposition);
if(res != ERROR_SUCCESS)
{
@@ -737,7 +737,7 @@ IceServiceInstaller::addSource(const string& source, const string& log, const st
// DLL.
//
res = RegSetValueExW(key, L"EventMessageFile", 0, REG_EXPAND_SZ,
- reinterpret_cast<const BYTE*>(IceUtil::nativeToWnative(0, 0, resourceFile).c_str()),
+ reinterpret_cast<const BYTE*>(IceUtil::stringToWstring(resourceFile).c_str()),
static_cast<DWORD>(resourceFile.length() + 1) * sizeof(wchar_t));
if(res == ERROR_SUCCESS)
@@ -795,11 +795,11 @@ IceServiceInstaller::removeSource(const string& source) const
// Check if we can delete the source sub-key
//
// We don't support to use a string converter with this tool, so don't need to
- // use string converters in calls to nativeToWnative.
+ // use string converters in calls to stringToWstring.
//
LONG delRes = RegDeleteKeyW(HKEY_LOCAL_MACHINE,
- IceUtil::nativeToWnative(0, 0, createSource(source,
- IceUtil::wnativeToNative(0, 0, subkey))).c_str());
+ IceUtil::stringToWstring(createSource(source,
+ IceUtil::wstringToString(subkey))).c_str());
if(delRes == ERROR_SUCCESS)
{
res = RegCloseKey(key);
@@ -807,7 +807,7 @@ IceServiceInstaller::removeSource(const string& source) const
{
throw "Could not close registry key handle: " + IceUtilInternal::errorToString(res);
}
- return IceUtil::wnativeToNative(0, 0, subkey);
+ return IceUtil::wstringToString(subkey);
}
++index;
diff --git a/cpp/test/Ice/custom/StringConverterI.cpp b/cpp/test/Ice/custom/StringConverterI.cpp
index dc1e2cfdbba..a879c58b9bb 100644
--- a/cpp/test/Ice/custom/StringConverterI.cpp
+++ b/cpp/test/Ice/custom/StringConverterI.cpp
@@ -8,7 +8,6 @@
// **********************************************************************
#include <StringConverterI.h>
-#include <IceUtil/Unicode.h>
using namespace std;
using namespace IceUtil;
@@ -48,7 +47,7 @@ Byte*
Test::WstringConverterI::toUTF8(const wchar_t* sourceStart, const wchar_t* sourceEnd, IceUtil::UTF8Buffer& buffer) const
{
wstring ws(sourceStart, sourceEnd);
- string s = IceUtil::wnativeToNative(0, 0, ws);
+ string s = IceUtil::wstringToString(ws);
size_t size = s.size();
Byte* targetStart = buffer.getMoreBytes(size, 0);
@@ -76,6 +75,6 @@ Test::WstringConverterI::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd
s[i] = sourceStart[--j];
}
- target = IceUtil::nativeToWnative(0, 0, s);
+ target = IceUtil::stringToWstring(s);
}
diff --git a/cpp/test/Ice/stringConverter/Server.cpp b/cpp/test/Ice/stringConverter/Server.cpp
index 4b9c6a78c20..7b0f9bcc978 100644
--- a/cpp/test/Ice/stringConverter/Server.cpp
+++ b/cpp/test/Ice/stringConverter/Server.cpp
@@ -31,14 +31,14 @@ public:
throw Test::BadEncodingException();
}
- return IceUtil::nativeToWnative(IceUtil::getProcessStringConverter(),
- IceUtil::getProcessWstringConverter(), msg);
+ return IceUtil::stringToWstring(msg, IceUtil::getProcessStringConverter(),
+ IceUtil::getProcessWstringConverter());
}
virtual string narrow(const wstring& wmsg, const Ice::Current&)
{
- return IceUtil::wnativeToNative(IceUtil::getProcessStringConverter(),
- IceUtil::getProcessWstringConverter(), wmsg);
+ return IceUtil::wstringToString(wmsg, IceUtil::getProcessStringConverter(),
+ IceUtil::getProcessWstringConverter());
}
virtual void shutdown(const Ice::Current& current)
diff --git a/cpp/test/IceGrid/deployer/Server.cpp b/cpp/test/IceGrid/deployer/Server.cpp
index 3d576116fa4..7673e082a6e 100644
--- a/cpp/test/IceGrid/deployer/Server.cpp
+++ b/cpp/test/IceGrid/deployer/Server.cpp
@@ -80,13 +80,13 @@ main(int argc, char* argv[])
#if defined(_WIN32)
wchar_t* value2 = _wgetenv(L"MY_ENV_UNICODE_VARIABLE");
- test(value2 != 0 && wstring(value2) == IceUtil::nativeToWnative(0, 0, unicodeVar));
+ test(value2 != 0 && wstring(value2) == IceUtil::stringToWstring(unicodeVar));
- wchar_t* value3 = _wgetenv(IceUtil::nativeToWnative(0, 0, varname1).c_str());
+ wchar_t* value3 = _wgetenv(IceUtil::stringToWstring(varname1).c_str());
test(value3 != 0 && wstring(value3) == L"2");
// Environment variables are case insensitive on Windows.
- wchar_t* value4 = _wgetenv(IceUtil::nativeToWnative(0, 0, varname1).c_str());
+ wchar_t* value4 = _wgetenv(IceUtil::stringToWstring(varname1).c_str());
test(value4 != 0 && wstring(value4) == L"2");
char* value5 = getenv("MY_WINDOWS_COMPOSED_VARIABLE");
diff --git a/cpp/test/IceUtil/inputUtil/Client.cpp b/cpp/test/IceUtil/inputUtil/Client.cpp
index 27a4a6522d3..d4f14acec12 100644
--- a/cpp/test/IceUtil/inputUtil/Client.cpp
+++ b/cpp/test/IceUtil/inputUtil/Client.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/Unicode.h>
#include <IceUtil/InputUtil.h>
#include <IceUtil/StringUtil.h>
#include <IceUtil/Options.h>
diff --git a/cpp/test/IceUtil/unicode/Client.cpp b/cpp/test/IceUtil/unicode/Client.cpp
index 63c2658dc32..62e115ce82e 100644
--- a/cpp/test/IceUtil/unicode/Client.cpp
+++ b/cpp/test/IceUtil/unicode/Client.cpp
@@ -7,7 +7,6 @@
//
// **********************************************************************
-#include <IceUtil/Unicode.h>
#include <IceUtil/FileUtil.h>
#include <IceUtil/StringConverter.h>
#include <TestCommon.h>
@@ -22,7 +21,7 @@ using namespace IceUtil;
using namespace std;
//
-// Note that each file starts with a BOM; nativeToWnative and wnativeToNative
+// Note that each file starts with a BOM; stringToWstring and wstringToString
// converts these BOMs back and forth.
//
@@ -48,7 +47,7 @@ main(int argc, char* argv[])
# ifdef __MINGW32__
dir = argv[1];
# else
- dir = IceUtil::wnativeToNative(0, 0, argv[1]);
+ dir = IceUtil::wstringToString(argv[1]);
# endif
dir += "\\";
#else
@@ -84,7 +83,7 @@ main(int argc, char* argv[])
test(isLegalUTF8Sequence(reinterpret_cast<const Byte*>(line.data()),
reinterpret_cast<const Byte*>(line.data() + line.size())));
lineNumber++;
- wstring wline = nativeToWnative(0, 0, line);
+ wstring wline = stringToWstring(line);
for(size_t i = 0; i < wline.length(); ++i)
{
@@ -157,7 +156,7 @@ main(int argc, char* argv[])
}
} while(bis.good());
- string s = wnativeToNative(0, 0, ws);
+ string s = wstringToString(ws);
IceUtilInternal::ifstream nbis((dir + "coeur.utf8"), ios_base::binary);
test(nbis.good());
@@ -208,10 +207,10 @@ main(int argc, char* argv[])
try
{
- wstring ws = IceUtil::nativeToWnative(0, 0, badUTF8[i]);
+ wstring ws = IceUtil::stringToWstring(badUTF8[i]);
test(false);
}
- catch(const IceUtil::UTFConversionException&)
+ catch(const IceUtil::IllegalConversionException&)
{}
}
@@ -225,10 +224,10 @@ main(int argc, char* argv[])
{
try
{
- string s = IceUtil::wnativeToNative(0, 0, badWstring[i]);
+ string s = IceUtil::wstringToString(badWstring[i]);
test(false);
}
- catch(const IceUtil::UTFConversionException&)
+ catch(const IceUtil::IllegalConversionException&)
{}
}