Date: Thursday, January 18, 2007 @ 15:04:31
Author: marc
Path: /cvsroot/carob/carob
Modified: include/StringCodecs.hpp (1.21 -> 1.22) src/Common.cpp (1.61 ->
1.62) test/01-Unit/TestStringCodecs.cpp (1.7 -> 1.8)
Since JavaSocket.cpp is now using its private one, removed global
StaticCodecs::utf8_codec and the functions fromUTF8() and toUTF8().
-----------------------------------+
include/StringCodecs.hpp | 16 ----------------
src/Common.cpp | 9 ++-------
test/01-Unit/TestStringCodecs.cpp | 9 +++++++--
3 files changed, 9 insertions(+), 25 deletions(-)
Index: carob/include/StringCodecs.hpp
diff -u carob/include/StringCodecs.hpp:1.21 carob/include/StringCodecs.hpp:1.22
--- carob/include/StringCodecs.hpp:1.21 Tue Jan 16 19:13:16 2007
+++ carob/include/StringCodecs.hpp Thu Jan 18 15:04:31 2007
@@ -178,12 +178,6 @@
*/
static std::wstring fromASCII(const std::string& in) throw (CodecException)
{ return ascii_codec.decode(in); }
- /** Converts UTF-8 encoded string to a wide string */
- static std::wstring fromUTF8(const std::string& in) throw (CodecException)
- { return utf8_codec.decode(in); }
- /** Converts a wide string to a UTF-8 encoded string */
- static std::string toUTF8(const std::wstring& in) throw (CodecException)
- { return utf8_codec.encode(in); }
/**
* Converts user's locale encoded string to a wide string<br>
* To be used for conversions of locale dependent strings, eg. system
messages
@@ -232,16 +226,6 @@
return StaticCodecs::toString(in);
}
-inline std::wstring fromUTF8(const std::string& in) throw (CodecException)
-{
- return StaticCodecs::fromUTF8(in);
-}
-
-inline std::string toUTF8(const std::wstring& in) throw (CodecException)
-{
- return StaticCodecs::toUTF8(in);
-}
-
} // namespace CarobNS
#endif // include only once
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.61 carob/src/Common.cpp:1.62
--- carob/src/Common.cpp:1.61 Wed Jan 17 17:23:31 2007
+++ carob/src/Common.cpp Thu Jan 18 15:04:31 2007
@@ -359,14 +359,9 @@
const CarobNS::MBSCodec
CarobNS::StaticCodecs::ascii_codec(std::locale::classic());
-// init order matters here, since a failure to init utf8_codec will
-// call user_codec
+// init order matters, since user_codec may be used to print error
+// messages in case of failures
const CarobNS::MBSCodec CarobNS::StaticCodecs::user_codec(tryuserlocale());
-#ifdef CAROB_USE_ICONV
-CarobNS::IconvCodec CarobNS::StaticCodecs::utf8_codec("UTF-8");
-#else
-const CarobNS::MBSCodec CarobNS::StaticCodecs::utf8_codec(tryUTF8locale());
-#endif
// decimal point initialization
wchar_t CarobNS::userDecimalPoint =
Index: carob/test/01-Unit/TestStringCodecs.cpp
diff -u carob/test/01-Unit/TestStringCodecs.cpp:1.7
carob/test/01-Unit/TestStringCodecs.cpp:1.8
--- carob/test/01-Unit/TestStringCodecs.cpp:1.7 Fri Mar 3 16:54:13 2006
+++ carob/test/01-Unit/TestStringCodecs.cpp Thu Jan 18 15:04:31 2007
@@ -48,6 +48,11 @@
const MBSCodec latin9_codec("[EMAIL PROTECTED]");
const MBSCodec iso7_codec("el_GR.iso88597");
+#ifdef CAROB_USE_ICONV
+ IconvCodec utf8_codec("UTF-8");
+#else
+ MBSCodec utf8_codec(tryUTF8locale());
+#endif
// TEST STRINGS
@@ -76,7 +81,7 @@
// ENCODE
- string utf8s(toUTF8(wide_cae));
+ string utf8s(utf8_codec.encode(wide_cae));
string latin9s(latin9_codec.encode(wide_cae));
string iso7s;
@@ -99,7 +104,7 @@
// DECODE BACK AND COMPARE
- CPPUNIT_ASSERT(0 == wide_cae.compare(fromUTF8(utf8s)));
+ CPPUNIT_ASSERT(0 == wide_cae.compare(utf8_codec.decode(utf8s)));
CPPUNIT_ASSERT(0 == wide_cae.compare(latin9_codec.decode(latin9s)));
CPPUNIT_ASSERT(0 == wide_pbk.compare(iso7_codec.decode(iso7s)));
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits