diff --git a/icu4c/source/common/common.vcproj b/icu4c/source/common/common.vcproj
index 807dcb10315..532b642a139 100644
--- a/icu4c/source/common/common.vcproj
+++ b/icu4c/source/common/common.vcproj
@@ -1168,6 +1168,10 @@
/>
+
+
diff --git a/icu4c/source/common/unicode/std_string.h b/icu4c/source/common/unicode/std_string.h
new file mode 100644
index 00000000000..62b89479bc6
--- /dev/null
+++ b/icu4c/source/common/unicode/std_string.h
@@ -0,0 +1,78 @@
+/*
+*******************************************************************************
+*
+* Copyright (C) 2009, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+*******************************************************************************
+* file name: std_string.h
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2009feb19
+* created by: Markus W. Scherer
+*/
+
+#ifndef __STD_STRING_H__
+#define __STD_STRING_H__
+
+/**
+ * \file
+ * \brief C++ API: Central ICU header for including the C++ standard
+ * header and for related definitions.
+ */
+
+#include "unicode/utypes.h"
+
+/**
+ * \def U_HAVE_STD_STRING
+ * Define whether the standard C++ (STL) header is available.
+ * @draft ICU 4.2
+ */
+#ifndef U_HAVE_STD_STRING
+#define U_HAVE_STD_STRING 1
+#endif
+
+#if U_HAVE_STD_STRING
+
+#include
+
+/**
+ * \def U_STD_NS
+ * Define the namespace to use for standard C++ (STL) classes.
+ * Either std or empty.
+ * @draft ICU 4.2
+ */
+
+/**
+ * \def U_STD_NSQ
+ * Define the namespace qualifier to use for standard C++ (STL) classes.
+ * Either std:: or empty.
+ * For example,
+ * U_STD_NSQ string StringFromUnicodeString(const UnicodeString &unistr);
+ * @draft ICU 4.2
+ */
+
+/**
+ * \def U_STD_NS_USE
+ * This is used to specify that the rest of the code uses the
+ * standard (STL) namespace.
+ * Either "using namespace std;" or empty.
+ * @draft ICU 4.2
+ */
+#ifndef U_STD_NSQ
+# if U_HAVE_NAMESPACE
+# define U_STD_NS std
+# define U_STD_NSQ U_STD_NS::
+# define U_STD_NS_USE using namespace U_STD_NS;
+# else
+# define U_STD_NS
+# define U_STD_NSQ
+# define U_STD_NS_USE
+# endif
+#endif
+
+#endif // U_HAVE_STD_STRING
+
+#endif // __STD_STRING_H__
diff --git a/icu4c/source/test/intltest/strtest.cpp b/icu4c/source/test/intltest/strtest.cpp
index 97620c921ff..ef1984fde3a 100644
--- a/icu4c/source/test/intltest/strtest.cpp
+++ b/icu4c/source/test/intltest/strtest.cpp
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2009, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: strtest.cpp
@@ -185,8 +185,52 @@ void StringTest::runIndexedTest(int32_t index, UBool exec, const char *&name, ch
#endif
}
break;
+ case 8:
+ name="TestStdNamespaceQualifier";
+ if(exec) {
+ TestStdNamespaceQualifier();
+ }
+ break;
+ case 9:
+ name="TestUsingStdNamespace";
+ if(exec) {
+ TestUsingStdNamespace();
+ }
+ break;
default:
name="";
break;
}
}
+
+// Syntax check for the correct namespace qualifier for the standard string class.
+void
+StringTest::TestStdNamespaceQualifier() {
+#if U_HAVE_STD_STRING
+ U_STD_NSQ string s="abc xyz";
+ U_STD_NSQ string t="abc";
+ t.append(" ");
+ t.append("xyz");
+ if(s!=t) {
+ errln("standard string concatenation error: %s != %s", s.c_str(), t.c_str());
+ }
+#endif
+}
+
+#if U_HAVE_STD_STRING
+// Now test that "using namespace std;" is defined correctly.
+U_STD_NS_USE
+#endif
+
+void
+StringTest::TestUsingStdNamespace() {
+#if U_HAVE_STD_STRING
+ string s="abc xyz";
+ string t="abc";
+ t.append(" ");
+ t.append("xyz");
+ if(s!=t) {
+ errln("standard string concatenation error: %s != %s", s.c_str(), t.c_str());
+ }
+#endif
+}
diff --git a/icu4c/source/test/intltest/strtest.h b/icu4c/source/test/intltest/strtest.h
index 5f342e10980..8d88c4ab668 100644
--- a/icu4c/source/test/intltest/strtest.h
+++ b/icu4c/source/test/intltest/strtest.h
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2009, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: strtest.h
@@ -15,6 +15,7 @@
/*
* Test character- and string- related settings in utypes.h,
* macros in putil.h, and constructors in unistr.h .
+ * Also basic tests for std_string.h .
*/
#ifndef __STRTEST_H__
@@ -33,6 +34,8 @@ private:
void TestEndian(void);
void TestSizeofTypes(void);
void TestCharsetFamily(void);
+ void TestStdNamespaceQualifier();
+ void TestUsingStdNamespace();
};
#endif