Date: Monday, December 19, 2005 @ 12:43:58
Author: marc
Path: /cvsroot/carob/carob
Modified: include/Common.hpp (1.20 -> 1.21) include/StringCodecs.hpp (1.2
-> 1.3) src/Common.cpp (1.14 -> 1.15)
test/01-Unit/TestStringCodecs.cpp (1.2 -> 1.3)
created utf8_codec and user_codec global variables.
-----------------------------------+
include/Common.hpp | 6 ++++++
include/StringCodecs.hpp | 8 ++------
src/Common.cpp | 10 ++++++++++
test/01-Unit/TestStringCodecs.cpp | 5 +----
4 files changed, 19 insertions(+), 10 deletions(-)
Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.20 carob/include/Common.hpp:1.21
--- carob/include/Common.hpp:1.20 Fri Dec 16 18:00:35 2005
+++ carob/include/Common.hpp Mon Dec 19 12:43:58 2005
@@ -22,6 +22,7 @@
#define _COMMON_H_
#include <string>
+#include "StringCodecs.hpp"
namespace CarobNS {
@@ -62,6 +63,11 @@
#endif
;
+// user-defined locale (typically set using LANG, LC_etc)
+extern const MBSCodec user_codec;
+extern const MBSCodec utf8_codec;
+
+
/** The current log level (set by setLogLevel) */
extern LogLevel currentLogLevel;
Index: carob/include/StringCodecs.hpp
diff -u carob/include/StringCodecs.hpp:1.2 carob/include/StringCodecs.hpp:1.3
--- carob/include/StringCodecs.hpp:1.2 Thu Dec 15 21:04:21 2005
+++ carob/include/StringCodecs.hpp Mon Dec 19 12:43:58 2005
@@ -23,13 +23,8 @@
#define CAROB_STRING_CODEC_HPP_
#include <locale>
-// #include <stdexcept> // runtime_error
-// TODO: it would be nice to be able to get this at runtime
-// (in a non-portable way quite obviously...)
-// On linux try "locale -a"
-#define NAME_OF_ANY_UTF8_LOCALE_AVAILABLE "en_US.utf8"
namespace CarobNS {
@@ -61,7 +56,8 @@
std::string encode(const std::wstring&) const throw (CodecException);
std::wstring decode(const std::string&) const throw (CodecException);
- // default converter using user-defined locale (typically LANG, LC_etc)
+ // ctor for the default converter using user-defined locale (typically
LANG, LC_etc)
+ // Use: MBSCodec(locale::classic()) for instance if you want the C locale
MBSCodec() :
loc(std::locale("")),
codecvt (std::use_facet<mbs_codecvt>(loc))
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.14 carob/src/Common.cpp:1.15
--- carob/src/Common.cpp:1.14 Fri Dec 16 18:00:35 2005
+++ carob/src/Common.cpp Mon Dec 19 12:43:58 2005
@@ -33,6 +33,16 @@
using std::wcerr;
using std::endl;
+// TODO: it would be nice to be able to get this at runtime
+// (in a non-portable way quite obviously...)
+// On linux try "locale -a"
+#define NAME_OF_ANY_UTF8_LOCALE_AVAILABLE "en_US.utf8"
+
+const CarobNS::MBSCodec CarobNS::user_codec;
+
+const CarobNS::MBSCodec
CarobNS::utf8_codec(CarobNS::trylocale(NAME_OF_ANY_UTF8_LOCALE_AVAILABLE));
+
+
void CarobNS::setLogLevel(const LogLevel l)
{
CarobNS::currentLogLevel = l;
Index: carob/test/01-Unit/TestStringCodecs.cpp
diff -u carob/test/01-Unit/TestStringCodecs.cpp:1.2
carob/test/01-Unit/TestStringCodecs.cpp:1.3
--- carob/test/01-Unit/TestStringCodecs.cpp:1.2 Mon Dec 19 11:43:05 2005
+++ carob/test/01-Unit/TestStringCodecs.cpp Mon Dec 19 12:43:58 2005
@@ -22,9 +22,9 @@
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
+#include "Common.hpp"
#include "TestStringCodecs.hpp"
-#include "StringCodecs.hpp"
using namespace CarobNS;
@@ -41,9 +41,6 @@
// on redhat:
// # TODO
- const MBSCodec user_codec;
-
- const MBSCodec utf8_codec(trylocale(NAME_OF_ANY_UTF8_LOCALE_AVAILABLE));
const MBSCodec latin9_codec("[EMAIL PROTECTED]");
const MBSCodec iso7_codec("el_GR.iso88597");
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits